wsh script to map drives referencing domain controller.

I have a network which is run on a single domain using MS Enterprise Server 2003. The domain controls 13 separate sites which each have their own domain controllers.

My boss wants me to implement a wsh script which will allow users to log on to and use only the mapped drives specified for their particular domain controller.

In other words, the drives for each user would be mapped on the domain controller machines as opposed to mapping them on the primary domain controller

I am a novice script writer..

I need help with the script and instructions on installing it.

Please help!


Who is Participating?
WeHeConnect With a Mentor Commented:
You should do that with Group Policies.
i am not sure if you want them to log on to the DC's. Its a security issue to not allow this.
but if yes, you have to modify the "Default Domain Controller Policy"
If they log on to normal clients, the "Default Domain Policy" counts.
browse through it and look if it can do, what you want to do :)
DrDAuthor Commented:
The question more specifically is this:

I have to write a scipt using WSH which I would implement using group
The script would map drives to user computers as they log on.
However, since we have one domain but a number of domain controllers (a
domain controller in each site), I need a way to map drives according to the
D.C the user is using to authenicate him/herself.
For example if a user is in Site A,using Domain controller A then the mapped
drive he/she would receive would be X:\ mapped to share A
If a user is in Site B, using Domain controller B then the mapped drive
he/she would receive X:\ mapped to share B.

The WshNetwork object allows you to map drives according to three
properties: UserName, Computer Name and UserDomain

For example to map a network drive according to User Domain would be

Set objNetwork = Wscript.CreateObject ("Wscipt.Network")
strUserDomain = objNetwork.UserDomain

If strUserDomain = "ACCOUNTING" Then
   objNetwork.MapNetworkDrive "X:", "\\fileserver01\accounting", True
Else if strUserDomain = "DEVELOPMENT" Then
   objNetwork.MapNewtorkDrive :X:",  "\\fileserver01\accounting", True
End If

However the WshNetwork object doesn't have a property to map drives
according to the Domain Controller one is trying to authenicate oneself

Does anyone have a way around this?
shard26Connect With a Mentor Commented:
I know a sure fire way in Dos shell scripting

You could use this.

NET USE X: %logonserver%\accounting

This will always map the drive to the share that is attached to the server you logged on from.  Now in some cases your users may log onto a server that is not local.  If this happens then access to that drive will be slow. Hope that helps.  If you have to use a WSH script you could always launch the dos script first then call the wsh script using the logon server as a switch

Start %logonserver%\netlogon\wshscript.vbs %logonserver%

Good luck
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.

All Courses

From novice to tech pro — start learning today.