Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group Policy Logon Script does not map drives on Client machines. 1

Status
Not open for further replies.

JaBurd311

MIS
Sep 21, 2001
24
US
I have a logon script that maps drives based upon group membership. When logging into the domain server the script runs and applies the mappings just fine. However when the script is run on the client machine nothing happens. No error messages etc.

I have run net use Z: \\Server\Share from the command line on the client machine and it maps just fine. I have checked all the GPO options and everything looks just the way it should according to documentation etc.

Any Ideas? .vbs Code posted below.

Thanks in advance.

Const Administration = "cn=Administration"
Const Center_Manager = "cn=Center_Manager"
Const Clinic_Staff = "cn=Clinic_Staff"
Const Clinician = "cn=Clinician"
Const Development = "cn=Development"
Const Education = "cn=Education"
Const Facilities = "Cn=Facilities"
Const Finance = "cn=Finance"
Const HR = "cn=HR"
Const Reception = "cn=Reception"
Const Admin = "cn=domain admins"

Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

Wscript.Echo strGroups

If instr(strGroups, Admin) Then

wshNetwork.MapNetworkDrive "F:", "\\Server\Pt_Services"
wshNetwork.MapNetworkDrive "G:", "\\Server\Clinicians"
wshNetwork.MapNetworkDrive "H:", "\\Server\Education"
wshNetwork.MapNetworkDrive "I:", "\\Server\Marketing_PA"
wshNetwork.MapNetworkDrive "J:", "\\Server\Volunteers"
wshNetwork.MapNetworkDrive "K:", "\\Server\HR"
wshNetwork.MapNetworkDrive "L:", "\\Server\Finance"
wshNetwork.MapNetworkDrive "M:", "\\Server\Grants"
wshNetwork.MapNetworkDrive "N:", "\\Server\Development"
wshNetwork.MapNetworkDrive "O:", "\\Server\Facilities"
wshNetwork.MapNetworkDrive "P:", "\\Server\Administrators"

ElseIf InStr(strGroups, Administration) Then

wshNetwork.MapNetworkDrive "F:", "\\Server\Pt_Services"
wshNetwork.MapNetworkDrive "G:", "\\Server\Clinicians"
wshNetwork.MapNetworkDrive "H:", "\\Server\Education"
wshNetwork.MapNetworkDrive "I:", "\\Server\Marketing_PA"
wshNetwork.MapNetworkDrive "J:", "\\Server\Volunteers"
wshNetwork.MapNetworkDrive "K:", "\\Server\HR"
wshNetwork.MapNetworkDrive "L:", "\\Server\Finance"
wshNetwork.MapNetworkDrive "M:", "\\Server\Grants"

ElseIf InStr(strGroups, Center_Manager) Then

wshNetwork.MapNetworkDrive "F:", "\\Server\Pt_Services"
wshNetwork.MapNetworkDrive "G:", "\\Server\Clinicians"

ElseIf inStr(strGroups, Clinic_Staff) Then

wshNetwork.MapNetworkDrive "F:", "\\Server\Pt_Services"

ElseIf instr(strGroups, Clinician) Then

wshNetwork.MapNetworkDrive "F:", "\\Server\Pt_Services"
wshNetwork.MapNetworkDrive "G:", "\\Server\Clinicians"

ElseIf instr(strGroups, Development) Then

wshNetwork.MapNetworkDrive "I:", "\\Server\Marketing_PA"
wshNetwork.MapNetworkDrive "M:", "\\Server\Grants"
wshNetwork.MapNetworkDrive "N:", "\\Server\Development"

ElseIf instr(strGroups, Education) Then

wshNetwork.MapNetworkDrive "I:", "\\Server\Marketing_PA"
wshNetwork.MapNetworkDrive "J:", "\\Server\Volunteers"
wshNetwork.MapNetworkDrive "M:", "\\Server\Grants"
wshNetwork.MapNetworkDrive "H:", "\\Server\Education"

ElseIf instr(strGroups, Facilities) Then

wshNetwork.MapNetworkDrive "O:", "\\Server\Facilities"

ElseIf instr(strGroups, Finance) Then

wshNetwork.MapNetworkDrive "L:", "\\Server\Finance"
wshNetwork.MapNetworkDrive "M:", "\\Server\Grants"

ElseIf instr(strGroups, HR) Then

wshNetwork.MapNetworkDrive "L:", "\\Server\Finance"
wshNetwork.MapNetworkDrive "M:", "\\Server\Grants"
wshNetwork.MapNetworkDrive "K:", "\\Server\HR"

End If
 
Your problem is because you are converting the string of group names to lower case, but not using lower case in your group name constants...

i.e.
Code:
Const Administration = "cn=Administration"
should be replaced with
Code:
Const Administration = "cn=administration"

When you do your comparison with InStr method the case must be the same for the 2 strings your are comparing.

In addition, I would suggest that you do some error checking to make sure that users are not members of multiple groups. I use a counter to ensure this...

Code:
strGrpCounter = 0

If instr(strGroups, Admin) Then
	strGrpCounter = strGrpCounter + 1
	If strGrpCounter > 1 Then
		WScript.Echo "You are a member of more than one script related group"
		WScript.Quit
	Else
		wshNetwork.MapNetworkDrive "F:", "\\Server\Pt_Services"
		{more mappings...}
	End If
End If
    
If InStr(strGroups, Administration) Then
	strGrpCounter = strGrpCounter + 1
	If strGrpCounter > 1 Then
		WScript.Echo "You are a member of more than one script related group"
		WScript.Quit
	Else
		wshNetwork.MapNetworkDrive "F:", "\\Server\Pt_Services"
		{more mappings...}
	End If
End If

etc...


Good Luck!

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
PScottC,

Many thanks for the reply! I will definately add some error checking into the script.

Alas, I figured out that the clients were trying to map the drives using \\servername. For some reason in DNS the \\servername was mapped to the network card that was configured but not plugged in. Hence, I couldn't get to anything on the server. After plugging in the second nic the script works just fine.

Thanks again! I would have been chasing the capitialization for days I'm sure.

JEB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top