(Msg. 1) Posted: Mon Nov 17, 2008 10:58 am
Post subject: Mapping network drives using a vbs script Archived from groups: microsoft>public>win2000>group_policy (more info?)
I have the following vbs script below....and it is used to map network drives
based on an Active Directory User's group membership. My username is a
member of the MGT IT Services group. So based on the script below, I should
get the Y drive. But, not only do I get the Y drive, but for some reason,
I get the "O" drive as well as the Y drive, and my username is not a part of
any group that gets the O drive...
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
'Removes curent mappings
objNetwork.RemoveNetworkDrive "L:", True, True
objNetwork.RemoveNetworkDrive "J:", True, True
objNetwork.RemoveNetworkDrive "Z:", True, True
objNetwork.RemoveNetworkDrive "R:", True, True
objNetwork.RemoveNetworkDrive "N:", True, True
objNetwork.RemoveNetworkDrive "O:", True, True
objNetwork.RemoveNetworkDrive "U:", True, True
objNetwork.RemoveNetworkDrive "S:", True, True
objNetwork.RemoveNetworkDrive "M:", True, True
objNetwork.RemoveNetworkDrive "I:", True, True
objNetwork.RemoveNetworkDrive "K:", True, True
objNetwork.RemoveNetworkDrive "Z:", True, True
objNetwork.RemoveNetworkDrive "X:", True, True
objNetwork.RemoveNetworkDrive "Y:", True, True
objNetwork.RemoveNetworkDrive "Q:", True, True
'Finds users group membership
'For Each strGroup in objUser.MemberOf
'strGroupPath = "LDAP://" & strGroup
'Set objGroup = GetObject(strGroupPath)
'strGroupName = objGroup.CN
If (IsMember(objUser, "MGT IT Services Group") = True) Then
(Msg. 2) Posted: Mon Dec 08, 2008 2:33 am
Post subject: RE: Mapping network drives using a vbs script [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Did you ever fix this problem? If so what did you do to correct it? I'm
having the same issues.
Thank You
Best Regards;
Oscar Martinez
"booker@mgt" wrote:
> I have the following vbs script below....and it is used to map network drives
> based on an Active Directory User's group membership. My username is a
> member of the MGT IT Services group. So based on the script below, I should
> get the Y drive. But, not only do I get the Y drive, but for some reason,
> I get the "O" drive as well as the Y drive, and my username is not a part of
> any group that gets the O drive...
>
>
>
>
>
>
>
> On Error Resume Next
>
>
>
> Set objSysInfo = CreateObject("ADSystemInfo")
>
> Set objNetwork = CreateObject("Wscript.Network")
>
>
>
> strUserPath = "LDAP://" & objSysInfo.UserName
>
> Set objUser = GetObject(strUserPath)
>
>
>
> 'Removes curent mappings
>
> objNetwork.RemoveNetworkDrive "L:", True, True
>
> objNetwork.RemoveNetworkDrive "J:", True, True
>
> objNetwork.RemoveNetworkDrive "Z:", True, True
>
> objNetwork.RemoveNetworkDrive "R:", True, True
>
> objNetwork.RemoveNetworkDrive "N:", True, True
>
> objNetwork.RemoveNetworkDrive "O:", True, True
>
> objNetwork.RemoveNetworkDrive "U:", True, True
>
> objNetwork.RemoveNetworkDrive "S:", True, True
>
> objNetwork.RemoveNetworkDrive "M:", True, True
>
> objNetwork.RemoveNetworkDrive "I:", True, True
>
> objNetwork.RemoveNetworkDrive "K:", True, True
>
> objNetwork.RemoveNetworkDrive "Z:", True, True
>
> objNetwork.RemoveNetworkDrive "X:", True, True
>
> objNetwork.RemoveNetworkDrive "Y:", True, True
>
> objNetwork.RemoveNetworkDrive "Q:", True, True
>
>
>
> 'Finds users group membership
>
> 'For Each strGroup in objUser.MemberOf
>
> 'strGroupPath = "LDAP://" & strGroup
>
> 'Set objGroup = GetObject(strGroupPath)
>
> 'strGroupName = objGroup.CN
>
>
>
> If (IsMember(objUser, "MGT IT Services Group") = True) Then
>
> objNetwork.MapNetworkDrive "Y:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\IT services", False
>
> End If
>
>
>
>
>
> If (IsMember(objUser, "MGT Career Services") = True) Then
>
> objNetwork.MapNetworkDrive "L:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Career Services", False
>
> objNetwork.MapNetworkDrive "J:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Career Svcs_Act", False
>
> objNetwork.MapNetworkDrive "Z:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Undergraduate Office", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Career Services SAs") = True) Then
>
> objNetwork.MapNetworkDrive "L:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Career Services", False
>
> objNetwork.MapNetworkDrive "J:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Career Svcs_Act", False
>
> objNetwork.MapNetworkDrive "Z:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Undergraduate Office", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT CIBER") = True) Then
>
> objNetwork.MapNetworkDrive "R:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\CIBER", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Communications") = True) Then
>
> objNetwork.MapNetworkDrive "R:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Communications", False
>
> objNetwork.MapNetworkDrive "N:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\DeanSuite", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Communications Share Guest access") = True) Then
>
> objNetwork.MapNetworkDrive "R:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Communications", False
>
> objNetwork.MapNetworkDrive "N:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\DeanSuite", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Dean Suite non HR") = True) Then
>
> objNetwork.MapNetworkDrive "L:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Building Operations", False
>
> objNetwork.MapNetworkDrive "N:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\DeanSuite", False
>
> objNetwork.MapNetworkDrive "O:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Accounting", False
>
> objNetwork.MapNetworkDrive "U:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Graduate Assistantship",
> False
>
> objNetwork.MapNetworkDrive "S:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Accounting\FAcS", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Development") = True) Then
>
> objNetwork.MapNetworkDrive "L:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Development", False
>
> objNetwork.MapNetworkDrive "R:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Communications", False
>
> objNetwork.MapNetworkDrive "M:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Development\Student Share",
> False
>
> objNetwork.MapNetworkDrive "N:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\DeanSuite", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Development SAs") = True) Then
>
> objNetwork.MapNetworkDrive "M:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Development\Student Share",
> False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Eview Users") = True) Then
>
> objNetwork.MapNetworkDrive "Y:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\eview", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Executive Masters") = True) Then
>
> objNetwork.MapNetworkDrive "I:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Executive Education", False
>
> objNetwork.MapNetworkDrive "J:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\EMSMOT_Act", False
>
> objNetwork.MapNetworkDrive "K:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\EMSMOT", False
>
> objNetwork.MapNetworkDrive "O:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Accounting", False
>
> objNetwork.MapNetworkDrive "L:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Executive Programs", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Executive Programs") = True) Then
>
> objNetwork.MapNetworkDrive "I:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Executive Education", False
>
> objNetwork.MapNetworkDrive "J:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\EMSMOT_Act", False
>
> objNetwork.MapNetworkDrive "K:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\EMSMOT", False
>
> objNetwork.MapNetworkDrive "O:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Accounting", False
>
> objNetwork.MapNetworkDrive "L:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Executive Programs", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Explab Share participants") = True) Then
>
> objNetwork.MapNetworkDrive "Z:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Explab", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Graduate Office") = True) Then
>
> objNetwork.MapNetworkDrive "M:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Graduate Office", False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT Grad Assistant Share") = True) Then
>
> objNetwork.MapNetworkDrive "U:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Graduate Assistantship",
> False
>
> End If
>
>
>
> If (IsMember(objUser, "MGT HR staff") = True) Then
>
> objNetwork.MapNetworkDrive "X:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Building Operations", False
>
> objNetwork.MapNetworkDrive "N:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\DeanSuite", False
>
> objNetwork.MapNetworkDrive "O:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Accounting", False
>
> objNetwork.MapNetworkDrive "Y:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Communications", False
>
> objNetwork.MapNetworkDrive "R:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Human Resources", False
>
> objNetwork.MapNetworkDrive "Q:",
> "\\fileserver01.tgm.domain.com\com\shares\groups\Accounting\Pcard", False
>
> End If
(Msg. 3) Posted: Mon Dec 08, 2008 7:56 am
Post subject: RE: Mapping network drives using a vbs script [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
I changed the script a little to the following:
Option Explicit
Dim objSysInfo, objNetwork, strUserPath, objUser
Dim adoCommand, adoConnection, strBase,
strAttributes
Dim objGroupList
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
objectSid equal to each
' value in tokenGroups array.
strFilter = "(|"
If (TypeName(arrbytGroups) = "Byte()") Then
' tokenGroups has one entry.
strFilter = strFilter & "(objectSid=" _
& OctetToHexStr(arrbytGroups) & ")"
ElseIf (UBound(arrbytGroups) > -1) Then
' TokenGroups is an array of two or more
objectSid's.
For k = 0 To UBound(arrbytGroups)
strFilter = strFilter & "(objectSid="
_
& OctetToHexStr(arrbytGroups(k))
& ")"
Next
Else
' tokenGroups has no objectSid's.
Exit Sub
End If
strFilter = strFilter & ")"
' Use ADO to search for groups whose
objectSid matches any of the
' tokenGroups values for this user or
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum