# Active Directory Logon Script



## MDub2112 (Apr 13, 2005)

I have a vbs script that I'm trying to run for users of a new Windows 2003 Server R2 Active Directory.

I keep getting a MS VBScript compilation error
Line 13 Char 33 Syntax error 800A03EA

I am by no means a programmer and am having one heck of a time figuring this out.
Can someone here give me a hand?? It is only mapping user home drives, a couple of network drives, then group drives.

Something I will say is that we are a very small company (50ppl) so I do not have any OUs all security groups are global domain groups (I know....shouldn't but...)


```
' Initialise Groups with Const
Const Accounting_GROUP = "cn=Accounting"
Const FIELD_GROUP = "cn=Field"
Const LAB_GROUP = "cn=Lab"
Const OPS_GROUP = "cn=Ops"
Const SALES_GROUP = "cn=Sales"
Const MGMT_GROUP = "cn=Managers"
Const USERS_GROUP = "cn=Users"
Const MAS90_GROUP = "cn=MAS90"
Const LIMS_GROUP = "cn=LIMS System"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:",
"\\emt.local\dfs\userhome\" & wshNetwork.UserName

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" &
ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, MAS90_GROUP) Then

    wshNetwork.MapNetworkDrive "m:",
    "\\emt.local\dfs\Accounting\mas90"

If InStr(strGroups, LIMS_GROUP) Then

    wshNetwork.MapNetworkDrive "o:",
    "\\emt.local\dfs\omega\"

If InStr(strGroups, ACCOUNTING_GROUP) Then

    wshNetwork.MapNetworkDrive "g:",
    "\\emt.local\dfs\groups\Accounting\"
    
ElseIf InStr(strGroups, FIELD_GROUP) Then

    wshNetwork.MapNetworkDrive "g:",
    "\\emt.local\dfs\groups\field\"

ElseIf InStr(strGroups, LAB_GROUP) Then

    wshNetwork.MapNetworkDrive "g:",
    "\\emt.local\dfs\groups\lab\"

ElseIf InStr(strGroups, OPS_GROUP) Then

    wshNetwork.MapNetworkDrive "g:",
    "\\emt.local\dfs\groups\ops\"

ElseIf InStr(strGroups, SALES_GROUP) Then

    wshNetwork.MapNetworkDrive "g:",
    "\\emt.local\dfs\groups\sales\"

ElseIf InStr(strGroups, MGMT_GROUP) Then

    wshNetwork.MapNetworkDrive "g:",
    "\\emt.local\dfs\groups\"


End If
```


----------



## MyName (Oct 25, 2001)

You had a few problems with continuing code on a second line. I cleaned that up for you. Also, you were missing some End If's near the bottom. I see that you're using ElseIf for certain cases. Are you doing that for a specific purpose? Generally, you'd want to use just If-End If around all your group check statements to see if they're in the group. I left your ElseIf's in there, but you may need to look at that.

' Initialise Groups with Const
Const Accounting_GROUP = "cn=Accounting"
Const FIELD_GROUP = "cn=Field"
Const LAB_GROUP = "cn=Lab"
Const OPS_GROUP = "cn=Ops"
Const SALES_GROUP = "cn=Sales"
Const MGMT_GROUP = "cn=Managers"
Const USERS_GROUP = "cn=Users"
Const MAS90_GROUP = "cn=MAS90"
Const LIMS_GROUP = "cn=LIMS System"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:" , "\\emt.local\dfs\userhome\" & wshNetwork.UserName

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & _
ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, MAS90_GROUP) Then

wshNetwork.MapNetworkDrive "m:", "\\emt.local\dfs\Accounting\mas90"
End If

If InStr(strGroups, LIMS_GROUP) Then

wshNetwork.MapNetworkDrive "o:", "\\emt.local\dfs\omega\"

End If

If InStr(strGroups, ACCOUNTING_GROUP) Then

wshNetwork.MapNetworkDrive "g:", "\\emt.local\dfs\groups\Accounting\"

ElseIf InStr(strGroups, FIELD_GROUP) Then

wshNetwork.MapNetworkDrive "g:", "\\emt.local\dfs\groups\field\"

ElseIf InStr(strGroups, LAB_GROUP) Then

wshNetwork.MapNetworkDrive "g:", "\\emt.local\dfs\groups\lab\"

ElseIf InStr(strGroups, OPS_GROUP) Then

wshNetwork.MapNetworkDrive "g:", "\\emt.local\dfs\groups\ops\"

ElseIf InStr(strGroups, SALES_GROUP) Then

wshNetwork.MapNetworkDrive "g:", "\\emt.local\dfs\groups\sales\"

ElseIf InStr(strGroups, MGMT_GROUP) Then

wshNetwork.MapNetworkDrive "g:", "\\emt.local\dfs\groups\"


End If


----------

