Ok, I am really having a tough time with this and need some help cleaning it up and fixing my error. This code is supposed to connect to LDAP and map the user's department S: drive and Division T: drive. The code works if you are getting an S: and T: but if the user doesn't have a Division, nothing gets mapped on my full script I run, on this one I get an error.
So I broke the entire full script down to just this portion. This is what happens: If my test user is in the first listed group only "COO_AP_Airport", the scirpt errors with "Line: 11 Char:1 Object not a collection" If I un-Rem the DIM line, same error ...
If the user IS a member of both groups below, they both get mapped properly. (The full script has many more departments and divisions)
Can anybody assist me please?? Line 11 is: "For Each strGroup in objUser.MemberOf"
Should the line to DIM those items be there or not and how do I fix it to where if the user is in only one group that one group gets mapped?
So I broke the entire full script down to just this portion. This is what happens: If my test user is in the first listed group only "COO_AP_Airport", the scirpt errors with "Line: 11 Char:1 Object not a collection" If I un-Rem the DIM line, same error ...
If the user IS a member of both groups below, they both get mapped properly. (The full script has many more departments and divisions)
Can anybody assist me please?? Line 11 is: "For Each strGroup in objUser.MemberOf"
Should the line to DIM those items be there or not and how do I fix it to where if the user is in only one group that one group gets mapped?
Code:
' VB Script Document
'These next lines connect to LDAP
'DIM strUserPath, strGroup, objUser, objSysInfo, strGroupPath, objGroup, strGroupName, objNetwork
Set objNetwork = CreateObject("WScript.Network")
Set objSysInfo = CreateObject("ADSystemInfo")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN
on error resume next
Select Case strGroupName
Case "COO_AP_Airport"
objNetwork.MapNetworkDrive "S:", "\\chldept\Drive\Airport"
Case "COO_AP_Administration"
objNetwork.MapNetworkDrive "T:", "\\chldept\Drive\Airport\COO_AP_Administration"
End Select
Next