A logon script that maps drives according to the users group memberships 
Author Message
 A logon script that maps drives according to the users group memberships

'~~Author~~. jerry Lees

'~~Script_Type~~. VBScript
'~~Sub_Type~~. LogonScripts
'~~Keywords~~. a logon script that maps drives according to the users group
memberships
'~~Comment~~.
'The script enumerates the groups in the domain and check to see that the
'user is or isn't a member of the group and maps drives accordingly.

'~~Script~~.
' written by jerry lees on 10/03/2000

' this is for 95/98 machines, they run login scripts before the user is
logged on so the username will always return NULL
' Note: there is a technet article on this topic... took me a while to find
it, (hope this helps someone)

Dim UserName
Username = ""

While UserName = ""
 on error resume next
 Set WSHNetwork = CreateObject("WScript.Network")
 on error resume next
 UserName = UCASE(WSHNetwork.UserName)
 on error resume next
 Set WSHNetwork = Nothing
WEnd

' end 95/98 wile/wend loop

' replace YOURDOMAIN with your domain name.
Set adsDomainGroups = GetObject("WinNT://YOURDOMAIN")
adsDomainGroups.Filter = Array("Group")

for each adsGroup in adsDomainGroups

 Group = Ucase(adsgroup.name)
 ' add new groups and drives below here
 If group = UCASE("Domain Admins") then CheckGroup adsgroup.name, Username,
"J:", "\\server1\sysadmin"
 If group = UCASE("Admins") then CheckGroup adsgroup.name, Username, "J:",
"\\server3\sysadmin"
 If group = UCASE("Producers") then CheckGroup adsgroup.name, Username,
"R:", "\\server2\ProjectDocs"
 If group = UCASE("Sales") then CheckGroup adsgroup.name, Username, "S:",
"\\server3\Sales"
 If group = UCASE("Administrative") then CheckGroup adsgroup.name, Username,
"M:", "\\server2\Administrative"
 If group = UCASE("Accounting") then CheckGroup adsgroup.name, Username,
"Q:", "\\server3\accntng"
 If group = UCASE("reports") then CheckGroup adsgroup.name, Username, "O:",
"\\Server4\reports"
 If group = UCASE("doorway") then CheckGroup adsgroup.name,
Username,"W:","\\server5\doorway"

next
set adsuser = Nothing
set adsDomain = nothing

'the line below was here for testing purposes and debugging
'msgbox("DONE!")

sub CheckGroup(GroupName, username, Drive, unc)
'the line below was here for testing purposes and debugging
' MsgBox(groupname & " - " & username)

' replace YOURDOMAIN with your domain name.
 Set AdsGroup = GetObject("WinNT://YOURDOMAIN/" & GroupName)

 Set ADSGROUPMEMBERSHIP = AdsGroup.Members()
 for each adsUser in adsgroupmembership
  If UCase(adsUser.name) = username Then MapDrive Drive, UNC
 next
End Sub

Sub mapdrive (driveletter, UNCString)
' MsgBox("Mapping Drive!")
 Set WSHNetwork = WScript.CreateObject("WScript.Network")
 On Error Resume Next
 WSHNetwork.MapNetworkDrive driveletter, Uncstring
End sub

****  END SCRIPTS ****

I hope that this script can help anyone.



Wed, 01 Oct 2003 03:41:23 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. A logon script that maps drives according to the users group memberships

2. Drive mapping according to group membership

3. vbscript logon script to determine what users are in what group to map a drive

4. Newbie - Mapping drives according to user and change default folders

5. Mapping drives based on group membership using ADSI with VBS

6. Mapping drives based on group membership

7. Mapping drives based on group membership using ADSI with VBS

8. Mapping Drives based on Group Membership for Win9x clients

9. Getting Win98 to map drives based upon Group Membership

10. Drive Mapping in Logon Script

11. Logon Script Drive Mapping

12. Drive Mapping Error in Logon Script

 

 
Powered by phpBB® Forum Software