Map drives based on (domain) group membership

WHat I want to do is have one script run at login for all users which will query AD for group membership and map the correct drives for each group.
user logs in
script gets all users group membership
Say user is a member of domain users, gp1, and gp2,
Script runs logon part
If member gp1           ///maps this
 map \\server\share
If member gp99      ///dosent map this
 map \\server\share

Ive tried using the Ifmember exe on the 2000 res kit but it dosent seem to work half the time.
A possibility is the script below but I cant get it to work properly. It will get the local username and echo this back (for testing) this part works. If you look at the strUser ="cn=administrator," you will note I need to change this to the variable USERNAME which dosent seem to work for me because even if I change strUser ="cn=administrator," to for example strUser ="cn=admin," the script errors out.

Can anyone fix my script or suggest a better way?

' UsermemberOf Adv.vbs
' To list the groups to which the administrator is a memberOf
' Author Guy Thomas
' Version 2.3 - May 2005
' ---------------------------------------------------------------'
Option Explicit
Dim objRootLDAP, objGroup, objUser, objOU, objmemberOf
Dim strOU, strUser, strDNSDomain, strLDAP, strList, USERNAME
Dim arrGroup
Dim objShell, WshShell, WshSysEnv, ComputerName, out, FSO, filesys, filetxt, Date
Dim strDriveLetter1, strNewName1, strDriveLetter2, strNewName2
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
Set fso = CreateObject("Scripting.FileSystemObject")

WScript.Echo "Username is " & USERNAME

' Commands to bind to AD and extract domain name
Set objRootLDAP = GetObject("LDAP://RootDSE")
strDNSDomain = objRootLDAP.Get("DefaultNamingContext")

' Build the LDAP DN from strUser, strOU and strDNSDomain
strList ="-------------------------------" & vbCr
strUser ="cn=administrator,"
strOU ="CN=Users,"
strLDAP ="LDAP://" & strUser & strOU & strDNSDomain
Set objUser = GetObject(strLDAP)

' Heart of the script, extract a list of Groups from memberOf
objmemberOf  = objUser.GetEx("memberOf")
For Each objGroup in objmemberOf
   objGroup = Mid(objGroup, 4, 330)
   arrGroup = Split(objGroup, "," )
   strList = strList & arrGroup(0) & vbcr

' Additional section to find the primary group.
If objUser.primaryGroupID = 513 Then
   strList = strList & vbCr & "Primary Group: " _
   & vbCr & "Domain Users" & vbCr
Else If objUser.primaryGroupID = 515 Then
   strList = strList & "Domain Computers"
Else strList = strList & "Maybe a Domain Controller"
End If
End If
WScript.Echo "Groups for " & Mid(strUser, 4, 99) & vbCr & strList


' End of Sample User memberOf  and primaryGroupID VBScript
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bernie SalvaggioIT ManagerCommented:
I use Kixtart to accomplish this.

The actual code in your kixtart script would just be

if INGROUP("domainName\groupName")
      use x: "\\serverName\share1a"
      use y: "\\serverName\share2$"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lucid911Author Commented:
Absolutely perfect. I cant thank you enough! I spend a week trying to get Vbscript to do what you showed me how to do in five mins.
Thanks again
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.