Hey there. Ok so I have been writing several variations of a logon script that maps 9 general drives and a personal drive only the user has access to based on their group membership. I can't seem to get it to map to the user drive on any users logon except my own (not the administrator but mine specifically). When I attempt to run the script under a different logon name, all the drives map except the one defined by the group membership. I just can't seem to locate what i'm missing. My script is below and any help would be greatly appreciated as to the point of over frustrated!! Every PC is running XP pro, Servers are running windows server 2003 standard edition. Please let me know what other information is needed if any. Thank you very much in advance!
Note: I changed the server names and group names to generalized ones.
***
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
Set ADSysInfo = CreateObject("ADSystemInfo")
'Get the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("LDAP://" & ADSysInfo.UserName)
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
'Waits to disconnect from existing drives
wscript.sleep 300
wshNetwork.MapNetworkDrive "m:", "\\server2\marketing"
wshNetwork.MapNetworkDrive "n:", "\\server4\accounting"
wshNetwork.MapNetworkDrive "o:", "\\server4\corporate"
wshNetwork.MapNetworkDrive "p:", "\\server3\public"
wshNetwork.MapNetworkDrive "q:", "\\server1\Technical-Services"
wshNetwork.MapNetworkDrive "r:", "\\server4\human-resources"
wshNetwork.MapNetworkDrive "s:", "\\server2\sales"
wshNetwork.MapNetworkDrive "t:", "\\server1\Engineering"
wshNetwork.MapNetworkDrive "v:", "\\server1\parts"
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf
Set objGroup = GetObject(strGroupPath)
strGroupPath = "LDAP://" & strGroup
strGroupName = objGroup.CN
'Check for group memberships and map appropriate drives
Select Case strGroupName
'Check for group memberships and take needed action
Case "Group"
wshNetwork.MapNetworkDrive "U:", "\\server3\information systems-users\" & wshNetwork.UserName
Case "Group1"
WshNetwork.MapNetworkDrive "U:", "\\server1\Applications-Users\" & wshNetwork.Username
Case "Group2"
wshNetwork.MapNetworkDrive "U:", "\\server2\Sales-Users\" & wshNetwork.UserName
Case "Group3"
wshNetwork.MapNetworkDrive "U:", "\\Server3\Human-Resources-Users\" & wshnetwork.Username
Case "Group4"
wshNetwork.MapNetworkDrive "U:", "\\server1\Service-users\" & wshNetwork.Username
'Set objNetwork = WScript.CreateObject("WScript.Network")
End Select
Next
WScript.Quit
Note: I changed the server names and group names to generalized ones.
***
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
Set ADSysInfo = CreateObject("ADSystemInfo")
'Get the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("LDAP://" & ADSysInfo.UserName)
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
'Waits to disconnect from existing drives
wscript.sleep 300
wshNetwork.MapNetworkDrive "m:", "\\server2\marketing"
wshNetwork.MapNetworkDrive "n:", "\\server4\accounting"
wshNetwork.MapNetworkDrive "o:", "\\server4\corporate"
wshNetwork.MapNetworkDrive "p:", "\\server3\public"
wshNetwork.MapNetworkDrive "q:", "\\server1\Technical-Services"
wshNetwork.MapNetworkDrive "r:", "\\server4\human-resources"
wshNetwork.MapNetworkDrive "s:", "\\server2\sales"
wshNetwork.MapNetworkDrive "t:", "\\server1\Engineering"
wshNetwork.MapNetworkDrive "v:", "\\server1\parts"
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf
Set objGroup = GetObject(strGroupPath)
strGroupPath = "LDAP://" & strGroup
strGroupName = objGroup.CN
'Check for group memberships and map appropriate drives
Select Case strGroupName
'Check for group memberships and take needed action
Case "Group"
wshNetwork.MapNetworkDrive "U:", "\\server3\information systems-users\" & wshNetwork.UserName
Case "Group1"
WshNetwork.MapNetworkDrive "U:", "\\server1\Applications-Users\" & wshNetwork.Username
Case "Group2"
wshNetwork.MapNetworkDrive "U:", "\\server2\Sales-Users\" & wshNetwork.UserName
Case "Group3"
wshNetwork.MapNetworkDrive "U:", "\\Server3\Human-Resources-Users\" & wshnetwork.Username
Case "Group4"
wshNetwork.MapNetworkDrive "U:", "\\server1\Service-users\" & wshNetwork.Username
'Set objNetwork = WScript.CreateObject("WScript.Network")
End Select
Next
WScript.Quit