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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon script doesn work

Status
Not open for further replies.

rrevuru

IS-IT--Management
Sep 23, 2004
37
0
0
US
Hello:

I did go through some of the old postings,couldnt find the solution for my problem

Iam trying to connect two shares on logon for every user.
1. Home 2. Public.
But when user logs in, only Home directory is connected not the public.

Iam not good in scripting. Please let me know what am i missing.


Here is the logon script
************************
Const Staff = "cn=Staff"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:", "\\FileServer\Users\" & wshNetwork.UserName

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

If InStr(strGroups, Staff) Then

wshNetwork.MapNetworkDrive "g:", "\\FileServer\Public\"

ENDIF
**************


Thanks,
 
Const Staff = "cn=Staff"

HERE you specify the string Staff -- it has a Capital Letter

strGroups = LCase(Join(CurrentUser.MemberOf))
HERE you do a lowercase conversion of the string CU.MemberOf that apparently contains group membership..

If InStr(strGroups, Staff) Then
and HERE you compare strGroups which is in lowercase to your constant Staff, which contains a Capital...

it could be that..
have you tested the validity of your strGroups & Staff stringsto see what they contain at runtime??




Aftertaf (david)
MCSA 2003
 
David..

Thanks for the email.

Here is the modified script iam using it right now. Iam still not able to get a connection to Public Drive.

**************
onst Staff = "cn=Staff"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:", "\\NS1\home" & wshNetwork.UserName

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)

strGroups = Join(CurrentUser.MemberOf)

If InStr(strGroups, Staff) Then
wshNetwork.MapNetworkDrive "g:", "\\NS1\FileServer\Public"
END IF

*******************
 

************************
Const Staff = "cn=Staff"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:", "\\FileServer\Users\" & wshNetwork.UserName

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

If InStr(strGroups, Staff) Then

wshNetwork.MapNetworkDrive "g:", "\\FileServer\Public\"

ENDIF
**************





 
sorry missed a dot

strGroups = LCase(Join(CurrentUser.getex("MemberOf")))
 
Fellas..

What am i doing wrong. My Management drives wont connect. I even included a Print statement inside "IF" loop and it prints out the IF statement, indicating it passed the IF loop test. But still gives me that error "Network Name cannot be found"

Here are things i made sure

1. User has correct perms
2. Its defined as GPO for that group.
3. Blocked inheritance from the parent

I dont know what else should i need to do

***************************************
Const MANAGEMENT = "cn=Management"



Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:", "\\NS1\home\" & wshNetwork.UserName
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, MANAGEMENT) Then
MsgBox "Hello Iam inside IF"
wshNetwork.MapNetworkDrive "y:", "\\NS1\FileServer\Management"
END IF
***************


Thanks
 
Ok..

Now i need little clarification.

If i three OU, Staff,Management,executive. These OUs have three corresponding Usergroups. I want to map network drives based on the group/OU.

Where do i apply the logon script.
1. Domain level
2. Group level. ( if this is the case, how do i manage the "Block inheritence",and "No Over ridden")


Here is the Group/OU allocation is made of

Executive is a sub-set of Managment
Management is a sub-set of Staff
Staff is a univesal set

What do you guys suggest.

Thanks,
 
I would not use a script at all. I would use ifmember.exe (put in your login scripts folder on the DC)and then use simple mapping (net use) commands to map the drives

Marty
Network Admin
Hilliard Schools
 
like terry 712 pointed out, i missed it too d'oh!
wshNetwork.MapNetworkDrive "y:", "\\NS1\FileServer\Management"

your UNC path it wrong!!!

i should be \\SERVER\SHARE


if not, you can use a very simple batch file to do a net use... and put in in a GPO linked to the OU...

Aftertaf (david)
MCSA 2003
 
Don't know if this got solved but this should work...

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:", "\\FileServer\Users\" & wshNetwork.UserName

Set objSysInfo = CreateObject("ADSystemInfo")

'-- Create the LDAP Path with the Distinguished name
strUserPath = "LDAP://" & objSysInfo.UserName

'-- Get the User collection
Set objUser = GetObject(strUserPath)

'-- Look at each group the user is a member of
For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup

'-- We are only interested in the Staff users
If Instr(strGroupPath, "Staff") Then
wshNetwork.MapNetworkDrive "g:", "\\FileServer\Public\"
End If

Next

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top