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!

Creating a login script 5

Status
Not open for further replies.

RockChalk

Technical User
Sep 18, 2003
136
US
I tried reading thru all the post about login scripts and I don't understand. Can someone tell me how to take a simple login script that maps our users to a userdata folder?

Here is the script.
net use H: \\servername\userdata

I saw that you ready shouldn't use your main domain controller to handle scripts. Is that right?

RC
 
works awesome!!! thanks. now we're moving. quick question, for the userstring variable, how do i add a $ after the name (there home drives are hidden shares)?
would it be
WSHNetwork.MapNetworkDrive "H:", "\\nyhomes01\userstring%$%",True or something else.
I guess my question is, how do i add static input to a variable ?


Thanks,
 
WSHNetwork.MapNetworkDrive "H:", "\\nyhomes01\" & userstring & "$",True

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
awesome once again. I have updaetd the script now with almost all of our mappings and groups but i have one more question. How can i find out the domain rather then hardcode it?
on these lines;

DomainString = "DomainName"
UserString = WSHNetwork.UserName

it figures out the username, but i would like it to figure out the domain name as well.
So far everything you have suggested and said has been right on, so thank you again for your assistance.

Thanks,
 
Sorry, i figured it out. below is what i put in place of the domainname variable

Set WSHDomain = GetObject("WinNT://[DOMAIN]")

and then i changed the reference in the script when it called for it.

Thanks,
 
i have another question actually, and i can't find any answers to it.
we are migrating from an NT4 domain to AD2003. We are using ADMT v2 to do the migration of the users, comaputers, and securities. Here is my question;
My main concerns are hte users home drives (username$), which maps right, and the shared drive that everyone accesses. They are able to gain accesst o them and have them mapped by being members of "domain users" which since it is a "built in" group, will not carry over. So, in the
section here;

'Maps drives needed by all
WSHNetwork.MapNetworkDrive "U:", "\\server\users",True
WSHNetwork.MapNetworkDrive "X:", "\\server\executables",True

once they are migrated, how will they get these drives mapped? all users are members of a group called "users" in the new AD2003 environment, not the built in group but we have created an OU called NYPAK, then beneath that are Accounts, then Users beneath that, which is where all users will be. So, question is, how do i map them? meaning, how do i say if in the users container, map them to these drives ?

Thanks,
 
ADMT will preserve user SIDs so you should not have aproblem with the file ownerships.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hello,

I noticed this looks like a pretty good place to start on trying to get drives mapped by group association. I've been able to get all parts of this script to work, with the exception of it pulling information from our AD to map drives based on the group membership. Can anyone tell me what parts of this script i will need to change in order to make it work with our AD infrastructure. Also, should i be using the LDAP command instead of the WinNT command under this portion of the code:

Set UserObj = GetObject("WinNT://UOFUCU" & DomainString & "/" & UserString)

Any help would be greatly appreciated.

Thanks in adavence,

Dustin
 
You need to make changes to this area:


'Check for group memberships and take needed action
Case "Admin"
WSHNetwork.MapNetworkDrive "w:", "\\Server\Admin Stuff",True


Where you see "Admin" should be replaced with your group name.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
yeah i figured as much for that, but do i need to change anything on the AD querying criteria. I just can't seem to get it to check for group membership and map the group specific drives.

Thanks for your help Mark!


Dustin
 
uucutech,
markdmac is using the NT provider because it is a little easier getting the script to work that way, as well as considering the NT provider sees it as flat, you won't make a typo trying to get the LDAP path correct. As far as using LDAP, you can, but just becomes a pain (check your path 4 times before trying it).
 
Is there anything i need to change in this bit of code for it to pull info from AD?

Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
DomainString = "DomainName"
UserString = WSHNetwork.UserName

Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

also, This script will work in a windows server 2003 AD setting correct?

Thanks for your help!

Dustin
 
DomainString = "DomainName"

You need to replace with your domain name where is says "DomainName"

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hello again,

I changed the "DomainName" string but still to no avail. It just doesnt want to pull info from our 2003 domain. Is there anything else i would need to change to make the script specific to our environment? this perhaps:

Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

i tried changing it to this:

Set UserObj = GetObject("WinNT://OurDoamin" & DomainString & "/" & UserString)

but still nothing.......sorry to keep buggin on this :(

Thanks again for all the help!

Dustin

 
Set UserObj = GetObject("WinNT://OurDoamin" & DomainString & "/" & UserString)

Would definately not work. If you want ot hardcode the domain name you can do so like this (using spidersparlor as a domain name example):

Set UserObj = GetObject("WinNT://spidersparlor/" & UserString)

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
thanks Mark! Your the man!

just one more question and then im done i swear:

i used this part to map the drives according to group membershipLike you said

Code:
'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups

Select Case GroupObj.Name
'Check for group memberships and take needed action
    Case "Admin"
        WSHNetwork.MapNetworkDrive "w:", "\\Server\Admin Stuff",True
    Case "Admin"
        WSHNetwork.MapNetworkDrive "x:", "\\Server\installs",True

but when i try to map multiple drives using the same "Case"
it doesnt' work. Is there any way of doing this?

Thanks again for all your help! Tek-Tips RULES!

Dustin
 
Try giving it a little pause to allow time for the first mapping:

Code:
Case "Admin"
    WSHNetwork.MapNetworkDrive "w:", "\\Server\Admin Stuff",True
    Wscript.Sleep 500          
    WSHNetwork.MapNetworkDrive "x:", "\\Server\installs",True

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
One again Mark rules!

Thanks for all your help on this matter Mark, your solutions worked splendidly.

Dustin
 
Hello again,
I am using the login script you posted and it works great witht he modifications that I had to make to it to work in our environment. But, i have come across a problem...
Once a user is converted to Windows XP we have a problem with the Homeshare mapping. When the login script runs (via groups policies -> User Configuration -> Windows Settings -> Scripts -> Logon )we point it to the generic login script we use for everyone (the one you posted above). In it the line that doesn't work on XP machines is WSHNetwork.MapNetworkDrive "H:", "\\nyhomes01\" & userstring & "$",True

On W2k machines it works fine though. Now, if I run the login script locally (copy it to my desktop and run it once the machine is loaded), i get the H drive as intended.
Why is this happening ? Does XP process scripts differently or is something else occurring ?
Any help would be greatly appreciated.


Thanks,
 
You could just point the users home directory to that share using the profile tab of the user account object in Active Directory. This doesn't solve your problem of the script not working so disregard everything i just said :p

Dustin
 
Can't really do that, i wish i could... One, that would be a ton of work for about 1000 users. And two, we want to only use one master logon script.


Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top