WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Mapping network drives using a vbs script

 
   Home -> Windows Other -> Group Policy RSS
Next:  Policies Not Applying to some PCs Intermittently  
Author Message
dummy.address

External


Since: Nov 17, 2008
Posts: 2



(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

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
Back to top
Login to vote
Oscar Martinez

External


Since: Dec 08, 2008
Posts: 1



(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
Back to top
Login to vote
dummy.address

External


Since: Nov 17, 2008
Posts: 2



(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)


'Removes curent mappings
On Error Resume Next
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 "X:", True, True
objNetwork.RemoveNetworkDrive "Y:", True, True
objNetwork.RemoveNetworkDrive "Q:", True, True
objNetwork.RemoveNetworkDrive "P:", True, True
On Error GoTo 0
Wscript.Sleep(5000)


If (IsMember(objUser, "MGT IT Services Group") =

True) Then
objNetwork.MapNetworkDrive "Y:", _
"\\filesrvr01.domain.toz\com\shares\groups\IT

services", False
End If


If (IsMember(objUser, "MGT Career Services") =

True) Then
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr01.domain.toz\com\shares\groups\Career

Services", False
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr01.domain.toz\com\shares\groups\Career

Svcs_Act", False
objNetwork.MapNetworkDrive "Z:", _
"\\filesrvr01.domain.toz\com\shares\groups\Underg

raduate Office", False
End If


If (IsMember(objUser, "MGT Career Services SAs")

= True) Then
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr01.domain.toz\com\shares\groups\Career

Services", False
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr01.domain.toz\com\shares\groups\Career

Svcs_Act", False
objNetwork.MapNetworkDrive "Z:", _
"\\filesrvr01.domain.toz\com\shares\groups\Underg

raduate Office", False
End If


If (IsMember(objUser, "MGT CIBER") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr01.domain.toz\com\shares\groups\CIBER"

, False
End If


If (IsMember(objUser, "MGT Communications") =

True) Then
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr01.domain.toz\com\shares\groups\Commun

ications", False
objNetwork.MapNetworkDrive "N:", _
"\\filesrvr01.domain.toz\com\shares\groups\DeanSu

ite", False
End If


If (IsMember(objUser, "MGT Communications Share

Guest access") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr01.domain.toz\com\shares\groups\Commun

ications", False
End If


If (IsMember(objUser, "MGT Dean Suite non HR") =

True) Then
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr01.domain.toz\com\shares\groups\Buildi

ng Operations", False
objNetwork.MapNetworkDrive "N:", _
"\\filesrvr01.domain.toz\com\shares\groups\DeanSu

ite", False
objNetwork.MapNetworkDrive "O:", _
"\\filesrvr01.domain.toz\com\shares\groups\Accoun

ting", False
End If


If (IsMember(objUser, "MGT Development") = True)

Then
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr01.domain.toz\com\shares\groups\Develo

pment", False
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr01.domain.toz\com\shares\groups\Commun

ications", False
objNetwork.MapNetworkDrive "M:", _
"\\filesrvr01.domain.toz\com\shares\groups\Develo

pment\Student Share", False
objNetwork.MapNetworkDrive "N:", _
"\\filesrvr01.domain.toz\com\shares\groups\DeanSu

ite", False
End If


If (IsMember(objUser, "MGT Development SAs") =

True) Then
objNetwork.MapNetworkDrive "M:", _
"\\filesrvr01.domain.toz\com\shares\groups\Develo

pment\Student Share", False
End If


If (IsMember(objUser, "MGT Eview Users") = True)

Then
objNetwork.MapNetworkDrive "Y:", _
"\\filesrvr01.domain.toz\com\shares\groups\eview"

, False
End If


If (IsMember(objUser, "MGT Executive Masters") =

True) Then
objNetwork.MapNetworkDrive "I:", _
"\\filesrvr01.domain.toz\com\shares\groups\Execut

ive Education", False
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr01.domain.toz\com\shares\groups\EMSMOT

_Act", False
objNetwork.MapNetworkDrive "K:", _
"\\filesrvr01.domain.toz\com\shares\groups\EMSMOT

", False
objNetwork.MapNetworkDrive "P:", _
"\\filesrvr01.domain.toz\com\shares\groups\Accoun

ting", False
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr01.domain.toz\com\shares\groups\Execut

ive Programs", False
End If


If (IsMember(objUser, "MGT Executive Programs") =

True) Then
objNetwork.MapNetworkDrive "I:", _
"\\filesrvr01.domain.toz\com\shares\groups\Execut

ive Education", False
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr01.domain.toz\com\shares\groups\EMSMOT

_Act", False
objNetwork.MapNetworkDrive "K:", _
"\\filesrvr01.domain.toz\com\shares\groups\EMSMOT

", False
objNetwork.MapNetworkDrive "P:", _
"\\filesrvr01.domain.toz\com\shares\groups\Accoun

ting", False
objNetwork.MapNetworkDrive "L:", _
"\\filesrvr01.domain.toz\com\shares\groups\Execut

ive Programs", False
End If


If (IsMember(objUser, "MGT Explab Share

participants") = True) Then
objNetwork.MapNetworkDrive "Z:", _
"\\filesrvr01.domain.toz\com\shares\groups\Explab

", False
End If

If (IsMember(objUser, "MGT FACS Admin Assistant

read access") = True) Then
objNetwork.MapNetworkDrive "S:", _
"\\filesrvr01.domain.toz\com\shares\groups\Accoun

ting\FAcS", False
End If


If (IsMember(objUser, "MGT Graduate Office") =

True) Then
objNetwork.MapNetworkDrive "M:", _
"\\filesrvr01.domain.toz\com\shares\groups\Gradua

te Office", False
End If


If (IsMember(objUser, "MGT Grad Assistant Share")

= True) Then
objNetwork.MapNetworkDrive "U:", _
"\\filesrvr01.domain.toz\com\shares\groups\Gradua

te Assistantship", False
End If


If (IsMember(objUser, "MGT HR staff") = True)

Then
objNetwork.MapNetworkDrive "X:", _
"\\filesrvr01.domain.toz\com\shares\groups\Buildi

ng Operations", False
objNetwork.MapNetworkDrive "N:", _
"\\filesrvr01.domain.toz\com\shares\groups\DeanSu

ite", False
objNetwork.MapNetworkDrive "O:", _
"\\filesrvr01.domain.toz\com\shares\groups\Accoun

ting", False
objNetwork.MapNetworkDrive "Y:", _
"\\filesrvr01.domain.toz\com\shares\groups\Commun

ications", False
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr01.domain.toz\com\shares\groups\Human

Resources", False
objNetwork.MapNetworkDrive "Q:", _
"\\filesrvr01.domain.toz\com\shares\groups\Accoun

ting\Pcard", False
End If


If (IsMember(objUser, "ILE Office") = True) Then
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr01.domain.toz\com\shares\groups\Instit

ute for LE", False
End If


If (IsMember(objUser, "ILE GRAs") = True) Then
objNetwork.MapNetworkDrive "J:", _
"\\filesrvr01.domain.toz\com\shares\groups\Instit

ute for LE", False
End If


If (IsMember(objUser, "MGT Tiger Share

participants") = True) Then
objNetwork.MapNetworkDrive "R:", _
"\\filesrvr01.domain.toz\com\shares\groups\Tiger"

, False
End If


If (IsMember(objUser, "MGT Undergraduate Office")

= True) Then
objNetwork.MapNetworkDrive "M:", _
"\\filesrvr01.domain.toz\com\shares\groups\Underg

raduate Office", False
End If


If (IsMember(objUser, "MGT Recruiting Share

Access") = True) Then
objNetwork.MapNetworkDrive "Q:", _
"\\filesrvr01.domain.toz\com\shares\groups\Recrui

ting", False
End If


If (IsMember(objUser, "MGT Faculty") = True) Then
objNetwork.MapNetworkDrive "S:", _
"\\filesrvr01.domain.toz\com\shares\groups\Accoun

ting\FAcS", False
End If


Function IsMember(ByVal objADObject, ByVal

strGroupNTName)
' Function to test for group membership.
' objADObject is a user or computer object.
' strGroupNTName is the NT name

(sAMAccountName) of the group to test.
' objGroupList is a dictionary object, with

global scope.
' Returns True if the user or computer is a

member of the group.
' Subroutine LoadGroups is called once for

each different objADObject.


Dim objRootDSE, strDNSDomain


' The first time IsMember is called, setup

the dictionary object
' and objects required for ADO.
If (IsEmpty(objGroupList) = True) Then
Set objGroupList =

CreateObject("Scripting.Dictionary")
objGroupList.CompareMode = vbTextCompare


Set adoCommand =

CreateObject("ADODB.Command")
Set adoConnection =

CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory

Provider"
adoCommand.ActiveConnection =

adoConnection


Set objRootDSE =

GetObject("LDAP://RootDSE")
strDNSDomain =

objRootDSE.Get("defaultNamingContext")


adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") =

False


' Search entire domain.
strBase = "<LDAP://" & strDNSDomain & ">"
' Retrieve NT name of each group.
strAttributes = "sAMAccountName"


' Load group memberships for this user or

computer into dictionary
' object.
Call LoadGroups(objADObject)
Set objRootDSE = Nothing
End If
If

(objGroupList.Exists(objADObject.sAMAccountName &

"\") = False) Then
' Dictionary object established, but

group memberships for this
' user or computer must be added.
Call LoadGroups(objADObject)
End If
' Return True if this user or computer is a

member of the group.
IsMember =

objGroupList.Exists(objADObject.sAMAccountName &

"\" _
& strGroupNTName)
End Function


Sub LoadGroups(ByVal objADObject)
' Subroutine to populate dictionary object

with group memberships.
' objGroupList is a dictionary object, with

global scope. It keeps track
' of group memberships for each user or

computer separately. ADO is used
' to retrieve the name of the group

corresponding to each objectSid in
' the tokenGroup array. Based on an idea by

Joe Kaplan.


Dim arrbytGroups, k, strFilter, adoRecordset,

strGroupName, strQuery


' Add user name to dictionary object, so

LoadGroups need only be
' called once for each user or computer.
objGroupList.Add objADObject.sAMAccountName &

"\", True


' Retrieve tokenGroups array, a calculated

attribute.
objADObject.GetInfoEx Array("tokenGroups"), 0
arrbytGroups = objADObject.Get("tokenGroups")


' Create a filter to search for groups with

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

computer.
strQuery = strBase & ";" & strFilter & ";" _
& strAttributes & ";subtree"
adoCommand.CommandText = strQuery
Set adoRecordset = adoCommand.Execute


' Enumerate groups and add NT name to

dictionary object.
Do Until adoRecordset.EOF
strGroupName =

adoRecordset.Fields("sAMAccountName").Value
objGroupList.Add

objADObject.sAMAccountName & "\" _
& strGroupName, True
adoRecordset.MoveNext
Loop
adoRecordset.Close


Set adoRecordset = Nothing
End Sub


Function OctetToHexStr(ByVal arrbytOctet)
' Function to convert OctetString (byte

array) to Hex string,
' with bytes delimited by \ for an ADO

filter.


Dim k
OctetToHexStr = ""
For k = 1 To Lenb(arrbytOctet)
OctetToHexStr = OctetToHexStr & "\" _
& Right("0" &

Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
Next
End Function




"Oscar Martinez" wrote:

> 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
Back to top
Login to vote
Display posts from previous:   
       Home -> Windows Other -> Group Policy 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
Categories:
 Windows XP
 Windows Vista
  Windows Other
 Office
 Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support