VBS Login Script issue

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I am trying to write a script that maps a drive on the basis of which
Active Directory user group, a user is part of.

This is what i have so far... but it doesnt seem to work, so I am
obviously doing something intrinsicly wrong.

Option Explicit

Dim objNetwork
Dim strUserDN,objUser
Dim objGroup1


Set objNetwork = CreateObject("WScript.Network")

' Bind to the user object in Active Directory with the LDAP provider.
Set objUser = GetObject("LDAP://"; & strUserDN)

' Bind to a group object in Active Directory with the LDAP provider.
Set objGroup1 = GetObject("LDAP://ou=Desktop Services,ou=User
Areas,dc=igi,dc=ig,dc=local")

' Map a network drive if the user is a member of the group.
If objGroup1.IsMember(objUser.AdsPath) Then
On Error Resume Next
objNetwork.MapNetworkDrive "W:", "\\igserv1\users"
If Err.Number <> 0 Then
On Error GoTo 0
objNetwork.RemoveNetworkDrive "W:", True, True
objNetwork.MapNetworkDrive "W:", "\\igserv1\users"
End If
On Error GoTo 0
End If

'Clean Up.


Set objNetwork = Nothing
Set objUser = Nothing
Set objGroup1 = Nothing

please help.

Becky

.



Relevant Pages

  • VBS login script help
    ... I am trying to write a script that maps a drive on the basis of which ... Set objNetwork = CreateObject ... ' Bind to the user object in Active Directory with the LDAP provider. ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: Sync AD computer description field with local computer description field.
    ... Is there a way (script) to find the current logged on user and query ... Active Directory is not designed to store short-lived, ... You should end up with a spreadsheet where the first column is the ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: VBS login script help
    ... > Dim strUserDN,objUser ... > ' Bind to the user object in Active Directory with the LDAP provider. ... > On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: Check for users with Blank Passwrods
    ... Dim strDN, objUser, strOldPW, strNewPW ... ' Use ADO to search Active Directory. ... Set objConnection = CreateObject ... On Error GoTo 0 ...
    (microsoft.public.windows.server.scripting)
  • Re: Check Group Membership
    ... I would like to use Active Directory groups to ... "GetUserNameA" (ByVal lpBuffer As String, ... Dim GroupObj As Object ... On Error GoTo getusergroups_Error ...
    (microsoft.public.access.formscoding)