Working on a project for an experiential learning class and well... I got asked to take care of the logon script, we're not ready to fully implement it yet, and I myself am not "good" with scripts, but I tried and this is what I have. I am wondering if someone that is knowledgeable could take a lookover and point out any mistakes-I can do more research as to why its wrong if I know to look at things.
Thanks for any help.
The goal of this script is to detect which group the user is a part of and then give the proper shares for the department. Payroll will have access to every department's "Payroll" share.
Department Key: HR, Accounting=ACT, Payroll=PYR, IT, Admin=AD, Production=PRD, Custodial=CST
Const ACT_GROUP = "cn=Accounting"
Const AD_GROUP = "cn=Admin"
Const CST_GROUP = "cn=Custodial"
Const HR_GROUP = "cn=Human Resources"
Const IT_GROUP = "cn=IT"
Const PYR_GROUP = "cn=Payroll"
Const PRD_GROUP = "cn=Production"
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" &
ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
If InStr(strGroups, ACT_GROUP) Then
wshNetwork.MapNetworkDrive "N:",
"\\FileServer\Accounting\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Accounting\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Accounting\ACTPayroll\"
ElseIf InStr(strGroups, AD_GROUP) Then
wshNetwork.MapNetworkDrive "N:",
"\\FileServer\Admin\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Admin\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Admin\ADPayroll\"
ElseIf InStr(strGroups, CST_GROUP) Then
wshNetwork.MapNetworkDrive "N:",
"\\FileServer\Custodial\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Custodial\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Custodial\CSTPayroll\"
ElseIf InStr(strGroups, HR_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Human Resources\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Human Resources\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Human Resources\HRPayroll\"
ElseIf InStr(strGroups, IT_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\IT\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\IT\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\IT\ITPayroll\"
ElseIf InStr(strGroups, PYR_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Payroll\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Payroll\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Payroll\PYRPayroll\"
wshNetwork.MapNetworkDrive "Q:",
"\\FileServer\Accounting\ACTPayroll\"
wshNetwork.MapNetworkDrive "R:",
"\\FileServer\Admin\ADPayroll\"
wshNetwork.MapNetworkDrive "S:",
"\\FileServer\Custodial\CSTPayroll\"
wshNetwork.MapNetworkDrive "T:",
"\\FileServer\Human Resources\HRPayroll\"
wshNetwork.MapNetworkDrive "U:",
"\\FileServer\IT\ITPayroll\"
wshNetwork.MapNetworkDrive "V:",
"\\FileServer\Production\PRDPayroll\"
ElseIf InStr(strGroups, PRD_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Production\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Production\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Production\PRDPayroll\"
End If
Thanks for any help.
The goal of this script is to detect which group the user is a part of and then give the proper shares for the department. Payroll will have access to every department's "Payroll" share.
Department Key: HR, Accounting=ACT, Payroll=PYR, IT, Admin=AD, Production=PRD, Custodial=CST
Const ACT_GROUP = "cn=Accounting"
Const AD_GROUP = "cn=Admin"
Const CST_GROUP = "cn=Custodial"
Const HR_GROUP = "cn=Human Resources"
Const IT_GROUP = "cn=IT"
Const PYR_GROUP = "cn=Payroll"
Const PRD_GROUP = "cn=Production"
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" &
ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
If InStr(strGroups, ACT_GROUP) Then
wshNetwork.MapNetworkDrive "N:",
"\\FileServer\Accounting\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Accounting\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Accounting\ACTPayroll\"
ElseIf InStr(strGroups, AD_GROUP) Then
wshNetwork.MapNetworkDrive "N:",
"\\FileServer\Admin\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Admin\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Admin\ADPayroll\"
ElseIf InStr(strGroups, CST_GROUP) Then
wshNetwork.MapNetworkDrive "N:",
"\\FileServer\Custodial\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Custodial\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Custodial\CSTPayroll\"
ElseIf InStr(strGroups, HR_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Human Resources\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Human Resources\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Human Resources\HRPayroll\"
ElseIf InStr(strGroups, IT_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\IT\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\IT\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\IT\ITPayroll\"
ElseIf InStr(strGroups, PYR_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Payroll\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Payroll\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Payroll\PYRPayroll\"
wshNetwork.MapNetworkDrive "Q:",
"\\FileServer\Accounting\ACTPayroll\"
wshNetwork.MapNetworkDrive "R:",
"\\FileServer\Admin\ADPayroll\"
wshNetwork.MapNetworkDrive "S:",
"\\FileServer\Custodial\CSTPayroll\"
wshNetwork.MapNetworkDrive "T:",
"\\FileServer\Human Resources\HRPayroll\"
wshNetwork.MapNetworkDrive "U:",
"\\FileServer\IT\ITPayroll\"
wshNetwork.MapNetworkDrive "V:",
"\\FileServer\Production\PRDPayroll\"
ElseIf InStr(strGroups, PRD_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Production\Department\"
wshNetwork.MapNetworkDrive "M:",
"\\FileServer\Production\Users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "O:",
"\\FileServer\Production\PRDPayroll\"
End If
Last edited: