'*******************************************************************
' Author: John Fuhrman
' Lenexa Outlink Data Center
' 10910 W. 87th
' Lenexa, Ks 66215
'
' Date: 11/16/2006
'
'* Parts used in this script are from the following author.
'
' NAME: LogonScript.vbs
'
' AUTHOR: Mark D. MacLachlan, The Spider's Parlor
' URL : [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE : 4/10/2003
'
' COMMENT: Enumerates current users' group memberships in given domain.
' Maps and disconnects drives and printers
'
'*******************************************************************
' On Error Resume Next
' Initialize Objects and Variables we are going to use in the script.
Dim strDomain, strUser
Dim WSHNetwork, objGroup , UserObj, UserNameObj
' initial object creation
Set WSHShell = CreateObject("WScript.Shell")
set WSHNetwork = WScript.createObject("WScript.Network")
DomainString = WSHNetwork.UserDomain 'Get the users Domain
UserString = WSHNetwork.UserName ' Get the user name
'Bind to the user object so that we can read it's values
Set UserObj = GetObject("WinNT://" & WSHNetwork.UserDomain & "/" & UserString)
strUser = UserObj.Name 'store users full name
strBank = (Left(UserObj.Name,3)) ' Grab the first 3 characters of the username
' WScript.Echo UCase(strBank)
' WScript.Echo "strUser: " & vbCrLf & strUser & vbCrLf
' WScript.Echo "DomainString: " & vbCrLf & DomainString & vbCrLf
' WScript.Echo "UserString: " & vbCrLf & UserString & vbCrLf
'****************************************************************************
' Check Username and Select Case
'****************************************************************************
Select Case UCase(strUser)
Case "GUEST"
WSHNetwork.AddWindowsPrinterConnection "\\PrintServer\printer01"
WSHNetwork.SetDefaultPrinter "\\PrintServer\printer01
[highlight]WSHNetwork.MapNetworkDrive "H:", "\\server\users\" & UserString,True[/highlight]
End Select
'*****************************************************************************
'Now check for group memberships and select the correct Case
'*****************************************************************************
strCounter = 0 ' Initialize counter
For Each GroupObj In UserObj.Groups
' WScript.Echo UCase(GroupObj.Name) ' (Insert echo command for troubleshooting)
Select Case UCase(GroupObj.Name) ' Convert to Upper Case for consistency
Case "DOMAIN ADMINS"
If strCounter > 0 Then
WScript.Echo "User is member of multiple banks"
' Exit For ' Causes For...Next loop to end
Else
strCounter = strCounter + 1 ' Increment counter for next loop
End If
WSHNetwork.AddWindowsPrinterConnection "\\lxolcdprn01\Lenexa8"
WSHNetwork.SetDefaultPrinter "\\lxolcdprn01\Lenexa8"
Case "ADMINISTRATORS"
If strCounter > 0 Then
WScript.Echo "User is member of multiple banks"
Exit For ' Causes For...Next loop to end
Else
strCounter = strCounter + 1 ' Increment counter for next loop
End If
' msgbox ("You are logged on as a Local Administrator!" & vbCrLf _
' & "Please be CAREFULL.")
End Select
Next