Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon script not mapping according to specified groups

Status
Not open for further replies.

ValF47

MIS
Jan 24, 2007
13
US
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
 
This post should be in the vbscript forum and not Exchange.

There are two problems that I see. First you make me sad [sadeyes] by not referencing your source. faq329-5798

Technically, your problem is most likely due to case sensitivity in the group names. Force all upper or all lower case and change the select statements to match as demonstrated in the FAQ. Also note that the groups must be domain global groups.

Also note that UserString is already created so in the Select Case you can use that instead of wshNetwork.Username
.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
I apologize for not having this in the correct forum. Please forgive me!!!! I have not been a very vivid user of forums. I came across this forum for a few other issues I was having and found them very useful, So I signed up! Thank you for your assistance. I believe I got it working now!!!!!! (next time I will make sure to give credit where credit is due!!!!) ;-)

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top