Hi all!
I have written a script to connect to the domain over the VPN connection after the user has logged onto his machine.
I need to map the network drive(s) for the user who belongs to a specific group, and I need to enumreate user's group membership using the WMI query. However, I cannot enumerate the group member using the WMI query.
The error message I got from the script is: AuthWithVPN4.vbs(25, 1) (null): 0x8004103A , where line 25 starts with "For Each objGroup In colGroups."
Any help will be greatly appreciated!
The code is sa follows:
Option Explicit
Dim strDomain, objLogon, oShell, objCancelled, strUserName, strPassword, strComputer
Dim objLocator, objWMIService, colGroups, objGroup
strDomain = "MyDomain"
Set objLogon = CreateObject("PassDlg.LogonDialog")
objLogon.ShowDialog "Enter Username and Password"
objlogon.AllowBlankUsername = False
objLogon.AllowBlankPassword = False
objCancelled = objLogon.Canceled
strUserName = objLogon.Username
strPassword = objLogon.Password
If objCancelled Then
WScript.quit
End If
'Establish domain credential with the domain controller
strComputer = "shelby"
Set objLocator = CreateObject( "WbemScripting.SWbemLocator" )
Set objWMIService = objLocator.ConnectServer( strComputer, "root/cimv2", strDomain &"\"& strUserName, strPassword )
objWMIService.Security_.impersonationlevel = 3
'Enumearte groups a user is member of
Set colGroups = objWMIService.ExecQuery( "Associators of {Win32_Group.Domain='& strDomain, Name='& strUserName} Where ResultClass = Win32_Group" )
For Each objGroup In colGroups
Wscript.Echo objGroup.Name
Next
Thanks!
CluM09
I have written a script to connect to the domain over the VPN connection after the user has logged onto his machine.
I need to map the network drive(s) for the user who belongs to a specific group, and I need to enumreate user's group membership using the WMI query. However, I cannot enumerate the group member using the WMI query.
The error message I got from the script is: AuthWithVPN4.vbs(25, 1) (null): 0x8004103A , where line 25 starts with "For Each objGroup In colGroups."
Any help will be greatly appreciated!
The code is sa follows:
Option Explicit
Dim strDomain, objLogon, oShell, objCancelled, strUserName, strPassword, strComputer
Dim objLocator, objWMIService, colGroups, objGroup
strDomain = "MyDomain"
Set objLogon = CreateObject("PassDlg.LogonDialog")
objLogon.ShowDialog "Enter Username and Password"
objlogon.AllowBlankUsername = False
objLogon.AllowBlankPassword = False
objCancelled = objLogon.Canceled
strUserName = objLogon.Username
strPassword = objLogon.Password
If objCancelled Then
WScript.quit
End If
'Establish domain credential with the domain controller
strComputer = "shelby"
Set objLocator = CreateObject( "WbemScripting.SWbemLocator" )
Set objWMIService = objLocator.ConnectServer( strComputer, "root/cimv2", strDomain &"\"& strUserName, strPassword )
objWMIService.Security_.impersonationlevel = 3
'Enumearte groups a user is member of
Set colGroups = objWMIService.ExecQuery( "Associators of {Win32_Group.Domain='& strDomain, Name='& strUserName} Where ResultClass = Win32_Group" )
For Each objGroup In colGroups
Wscript.Echo objGroup.Name
Next
Thanks!
CluM09