nkeever
asked on
Mapp network drives with user group membership
I would like to map drives based on group membership. I have tried the following but get an error on line 21 Char: 1 error: The specified domain either does not exist or could not be contacted. code:8007054B Source:(null)
Const IT = "cn=it"
Const CORPORATE = "cn=corporate"
Const SERVICES = "cn=services"
Const UNIVERSITY = "cn=university"
' ========================== ========== ========== ========
' MAP HOME DRIVE H:
' ========================== ========== ========== ========
Set wshNetwork = CreateObject("WScript.Netw ork")
wshNetwork.MapNetworkDrive "h:", "\\pways50-fs1\Profiles\" & wshNetwork.UserName
' ========================== ========== ========== ========
' COMPILE USER GROUP MEMBERSHIPS
' ========================== ========== ========== ========
set ADSysInfo = CreateObject("ADSystemInfo ")
set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
if IsArray(CurrentUser.Member Of) then
strGroups = LCase(Join(CurrentUser.Mem berOf))
' else
'strGroups = LCase(CurrentUser.MemberOf )
end if
'set ADSysInfo = nothing
'set CurrentUser = nothing
' ========================== ========== ========== ========
' MAP DRIVES
' ========================== ========== ========== ========
If InStr(strGroups, IT) Then
wshNetwork.MapNetworkDrive "i:", "\\pways50-fs1\IT"
'
ElseIf InStr(strGroups, CORPORATE) Then
wshNetwork.MapNetworkDrive "x:", "\\pways50-fs1\corporate"
ElseIf InStr(strGroups, SERVICES) Then
wshNetwork.MapNetworkDrive "s:", "\\pways50-fs1\services"
ElseIf InStr(strGroups, UNIVERSITY) Then
wshNetwork.MapNetworkDrive "u:", "\\pways50-fs1\university"
End If
WScript.Echo "Script is complete."
Two objects for this project. 1) I would like one script to map network drives for my users. 2) After 8 hours i lose my connection to the server. I can either log back in or remap the drives. However i can not map the drives with the user that is logged in. i have to use the administrator account and password for the server.
Sorry for the log post.
thanks for your help.
Const IT = "cn=it"
Const CORPORATE = "cn=corporate"
Const SERVICES = "cn=services"
Const UNIVERSITY = "cn=university"
' ==========================
' MAP HOME DRIVE H:
' ==========================
Set wshNetwork = CreateObject("WScript.Netw
wshNetwork.MapNetworkDrive
' ==========================
' COMPILE USER GROUP MEMBERSHIPS
' ==========================
set ADSysInfo = CreateObject("ADSystemInfo
set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
if IsArray(CurrentUser.Member
strGroups = LCase(Join(CurrentUser.Mem
' else
'strGroups = LCase(CurrentUser.MemberOf
end if
'set ADSysInfo = nothing
'set CurrentUser = nothing
' ==========================
' MAP DRIVES
' ==========================
If InStr(strGroups, IT) Then
wshNetwork.MapNetworkDrive
'
ElseIf InStr(strGroups, CORPORATE) Then
wshNetwork.MapNetworkDrive
ElseIf InStr(strGroups, SERVICES) Then
wshNetwork.MapNetworkDrive
ElseIf InStr(strGroups, UNIVERSITY) Then
wshNetwork.MapNetworkDrive
End If
WScript.Echo "Script is complete."
Two objects for this project. 1) I would like one script to map network drives for my users. 2) After 8 hours i lose my connection to the server. I can either log back in or remap the drives. However i can not map the drives with the user that is logged in. i have to use the administrator account and password for the server.
Sorry for the log post.
thanks for your help.
ASKER
Thanks for the reply. However i get the same error?
Add the following line to the beginning of the script.
on error resume next
on error resume next
ASKER
So if i resume on error and skip the command to set my currentUser how will the strGroups command work?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok so maybe my domain is not set up correctly. I am able to get the first drive mapped (wshNetwork.MapNetworkDriv e "h:", "\\pways50-fs1\Profiles\" & wshNetwork.UserName) but not the other drives. the user i am using is only a member for the IT group.
ASKER
Thanks for your help dasmcse. I needed to have a DNS server installed to run my script.
set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
to
set CurrentUser = GetObject("GC://" & ADSysInfo.UserName)