Mapp network drives with user group membership
Posted on 2006-11-03
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.Network")
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.MemberOf) then
strGroups = LCase(Join(CurrentUser.MemberOf))
'strGroups = LCase(CurrentUser.MemberOf)
'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"
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.