B
booker@mgt
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
If (IsMember(objUser, "ILE Office") = True) Then
objNetwork.MapNetworkDrive "J:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Institute for LE", False
End If
If (IsMember(objUser, "ILE GRAs") = True) Then
objNetwork.MapNetworkDrive "J:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Institute for LE", False
End If
If (IsMember(objUser, "MGT Tiger Share participants") = True) Then
objNetwork.MapNetworkDrive "R:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Tiger", False
End If
If (IsMember(objUser, "MGT Undergraduate Office") = True) Then
objNetwork.MapNetworkDrive "M:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Undergraduate Office", False
End If
If (IsMember(objUser, "MGT Recruiting Share Access") = True) Then
objNetwork.MapNetworkDrive "Q:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Recruiting", False
End If
If (IsMember(objUser, "MGT Faculty") = True) Then
objNetwork.MapNetworkDrive "S:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Accounting\FAcS", False
End If
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
If (IsMember(objUser, "ILE Office") = True) Then
objNetwork.MapNetworkDrive "J:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Institute for LE", False
End If
If (IsMember(objUser, "ILE GRAs") = True) Then
objNetwork.MapNetworkDrive "J:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Institute for LE", False
End If
If (IsMember(objUser, "MGT Tiger Share participants") = True) Then
objNetwork.MapNetworkDrive "R:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Tiger", False
End If
If (IsMember(objUser, "MGT Undergraduate Office") = True) Then
objNetwork.MapNetworkDrive "M:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Undergraduate Office", False
End If
If (IsMember(objUser, "MGT Recruiting Share Access") = True) Then
objNetwork.MapNetworkDrive "Q:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Recruiting", False
End If
If (IsMember(objUser, "MGT Faculty") = True) Then
objNetwork.MapNetworkDrive "S:",
"\\fileserver01.tgm.domain.com\com\shares\groups\Accounting\FAcS", False
End If