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

Mapping drives to a different domian using vbscript

Status
Not open for further replies.

kachbo1

IS-IT--Management
Nov 16, 2004
40
GB
Hi guys,

We are using Windows 2000 AD on Domain 1 and 2.

We have 2 domains. Some of our users require access to files on the other domain. At the moment we have created shortcuts on the desktop to the other domain which allows them access to those drives (they have to authenticate to the other domain).

My question is can I create a vbscript run through group policies which will map drives to a file server residing in domain 2? If the users have to authenticate again, it does not matter.

I can map drives on domain 1 without any problems using vbscripting, but cannot map the drives for domain 2.

Appreciate any help.

Kachbo
 
Try something like this:

Code:
StrDomain = "domain.com"
set net = createObject("wscript.network")
Struser = net.username

DispUserInWhichGroup()

Function DispUserInWhichGroup()
On error resume next
Dim Group
Dim User
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
For Each Group in User.Groups

Select case group.name

Case "BIS-users"
Net.RemoveNetworkDrive "I:"
Net.MapNetworkDrive "I:","\\10.1.1.1\DATA\Afdelingen\DIR", false, "domain\username", "password"

Case "Domain Users"
Net.RemoveNetworkDrive "H:"
Net.RemoveNetworkDrive "P:"
Net.MapNetworkDrive "H:", "\\server\users\" & net.username
Net.MapNetworkDrive "P:", "\\server\data\PROGS"
Case Else

End select
Next
End Function
 
I am a bit new to vb scripting.

I am using the following script to map drives for different mebers of different groups. I have about 20 groups and I would like to create one large script to map drives according to group membership. Can somebody help me out with:

1. Is the existing script correct and
2. Show me the correct way.

Kachbo

Set objnetwork = Wscript.CreateObject("WScript.Network")

strUserName = ObjNetwork.UserName

on error resume next

objnetwork.removenetworkdrive "H:"

objnetwork.mapnetworkdrive "H:" , "\\server\users$\" & strUserName , true


If IsMember("Group1") Then

objnetwork.removenetworkdrive "Q:"

objnetwork.mapnetworkdrive "Q:" , "\\server\share$" , True

EndIf

If IsMember("Group2") Then

objnetwork.removenetworkdrive "G:"

objnetwork.mapnetworkdrive "G:" , "\\server\share$" , True

End If

Wscript.Quit
 
Hello kachbo1,

If you take the advices from rijay:
as well as utilman here, you will see that both approaches are first to bind to the (domain) user with WinNT provider and the groups user belongs to, (ismember), will be exposed as the object's properties. And you map drives according to the group's name you "discover" along the way.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top