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

map hidden share

Status
Not open for further replies.

framfram

IS-IT--Management
May 24, 2006
17
FR
Hi All,

I would like to map username$ shares. Can someone tell me how I can vbscript this when user logs into the domain : if username$ share exist then map it else go to next command ?
I'm very very bad in scripting so please write down the full script with Dim, Set ... etc

Thanks a lot for your help ...
 
please write down the full script with Dim, Set ... etc
Are you aware that TT is NOT AN HELP DESK ?
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

Here is the script. I also have a problem with the section of membergroup shares , the script maps all the drives even if I don't belong to the group.
Thanks ..

ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj
Dim objADObject, strGroup, strDNSDomain
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set objADObject = getObject("LDAP://OU=gprs,OU=du,DC=dom,DC=com")
DomainString = objDomain.Get("dom.com")
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
UserString = WSHNetwork.UserName
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
wscript.sleep 300
For Each GroupObj In UserObj.Groups
strGroup = "SALES"
If IsMember(objADObject, strGroup) Then
WSHNetwork.MapNetworkDrive "P:", "\\server\sales",True
Else
End If
strGroup = "TECH"
If IsMember(objADObject, strGroup) Then
WSHNetwork.MapNetworkDrive "M:", "\\server\tech1",True
WSHNetwork.MapNetworkDrive "I:", "\\server\tech$",True
Else
End If
strGroup = "FINANCES"
If IsMember(objADObject, strGroup) Then
WSHNetwork.MapNetworkDrive "P:", "\\server\finance",True
Else
End If
Next
wscript.quit
 
thats because you ahve on error resume next, if statements behave not as you would expect when there is an error in a method call that you use as part of the If

your for each loop is ok but you are not then doign a string comparision on GroupObj, instead you are doing some IsMember rubbish on an OU
 
Hi Markdmac,

I first used yours but it didn't work for membergroup mapping. I replace the global group and the network share ..
Is that because my groups are created in an OU that I have created. Must I declare it somewhere ?

Thanks ...
 
Teh groups have to be global groups and the names need to match in the select case statement. I prefer to force all upper case or all lower case names for the comparrison to ensure the Select Case will find the match.

If it did not work for you, then more than likely you have not added the names as they appear from AD.

For testing, add one user to every group and run a version of the script that will just echo out the group names for you like this:

Code:
For Each GroupObj In UserObj.Groups
    GroupList = GroupList & GroupObj.Name & vbCrLf
Next
MsgBox GroupList

With that list you will know how AD is reporting the group names and can set your script accordingly.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
1)Testing the code, I realized that the script echoed just a blank msgbox. When I add the user in the admins group then I got the list of different groups the user belongs to ???
2)And even then, the network shares are not mapped and the names I set in the script, are iddentical to what appeared in the msgbox...
For the first point I guess it's a right problem, but for the second one ???Any ideas ???

Thanks ...


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top