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!

need to add group

Status
Not open for further replies.

superhl

IS-IT--Management
Dec 16, 2001
20
0
0
US
I am having issues on some windows 7 mapping the drive "M". How do I create an "if else" so that only the members of the group can login to strRemotePath2 = "\\encsd3\Data\PrintShop". Thanks

'Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3
Dim strDriveLetter1, strDriveLetter2, strDriveLetter3
strDriveLetter1 = "S:"
strDriveLetter2 = "M:"
strDriveLetter3 = "I:"
strRemotePath1 = "\\ENCSD3\data\Shared"
strRemotePath2 = "\\encsd3\Data\PrintShop"
strRemotePath3 = "\\encsd3\Apps"
Set objNetwork = CreateObject("WScript.Network")
' Section which maps two drives, M: and P:
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3
' Extra code just to add a message box
' WScript.Echo "Map drives " & strDriveLetter1 & " & " & strDriveLetter2 & " & strDriveLetter3 & "
' End of Windows Logon Script Example
' GroupMap.vbs
' VBScript to test group membership
' Script can be amended to actually MapNetworkDrive
' Author Guy Thomas ' Version 3.3 - May 2010
' ----------------------------------------------------'
Dim objUser, CurrentUser
Dim strGroup
' Initialise Groups with Const
Const Test_Group = "cn=Test"
Const Admin_Group = "cn=Admin"
Const Teachers_Group = "cn=Teachers"
Const Students_Group = "cn=Students"
Const Users_Group = "cn=Users"
' Create objects and extract strGroup values
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
strGroup = LCase(Join(CurrentUser.MemberOf))
' If logic testing strGroup for the values in Const groups
If InStr(strGroup, lcase(Test_Group)) Then
WScript.Echo "Test "
objNetwork.MapNetworkDrive "H:", "\\encsd3\Data\USERS\test" _
& objNetwork.UserName
' For a production script remove the WScript
' Activate mapnetworkdrive by removing the apostrophes (' Rem)
ElseIf InStr(strGroup, lcase(Admin_Group)) Then
'WScript.Echo " Admin "
objNetwork.MapNetworkDrive "H:", "\\encsd3\data\users\admin\"_
& objNetwork.UserName
ElseIf InStr(strGroup, lcase(Teachers_Group)) Then
'WScript.Echo " Teachers " & strGroup
objNetwork.MapNetworkDrive "H:", "\\encsd3\Data\USERS\Teachers" _
& objNetwork.UserName
ElseIf InStr(strGroup, lcase(Students_Group)) Then
'WScript.Echo " Students "
objNetwork.MapNetworkDrive "H:", "\\encsd3\data\users\STUDENTS" _
& objNetwork.UserName
End If
'Wscript.Echo "Finished Testing for Groups "
WScript.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top