' VBScipt for Windows AD-Domain user login script with mapped network drive & mapped printer support----------'
' v1.1--------------------------------------------------------------------------------------------------------'
' dmoranda.co.uk copyright 2009-------------------------------------------------------------------------------'
' ------------------------------------------------------------------------------------------------------------'
Option Explicit
'Defines a list for the variable values
Dim wshNetwork
Dim ADSysInfo
Dim CurrentUser
Dim strGroups
Dim arrGroups
Const SUPPORT_GROUP = "cn=support,ou=acc,ou=backoffice,dc=mydomain,dc=com"
Const FINANCE_GROUP = "cn=finance,ou=mky,ou=backoffice,dc=mydomain,dc=com"
Const PROVISIONING_GROUP = "cn=provisioning,ou=acc,ou=backoffice,dc=mydomain,dc=com"
Const SALES_GROUP = "cn=sales,ou=mky,ou=backoffice,dc=mydomain,dc=com"
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
'Map Users home directory to h:\
wshNetwork.MapNetworkDrive "h:", "\\****\Users$\" & wshNetwork.UserName
On Error Resume Next
arrGroups = CurrentUser.GetEx("MemberOf")
If (Err.Number = 0) Then
On Error GoTo 0
strGroups = LCase(Join(arrGroups))
If InStr(strGroups, "SUPPORT_GROUP") Then
wshNetwork.MapNetworkDrive "s:", "\\****\DATA"
End If
If InStr(strGroups, "FINANCE_GROUP") Then
wshNetwork.MapNetworkDrive "f:", "\\****\finance"
wshNetwork.MapNetworkDrive "s:", "\\****\DATA"
End If
If InStr(strGroups, "PROVISIONING_GROUP") Then
wshNetwork.MapNetworkDrive "s:", "\\****\DATA"
End If
If InStr(strGroups, "SALES_GROUP") Then
wshNetwork.MapNetworkDrive "s:", "\\****\DATA"
End If
End If
On Error GoTo 0