Link to home
Start Free TrialLog in
Avatar of Shakthi777
Shakthi777Flag for Afghanistan

asked on

SBS 2008 Login (VB) Script runs but not mapping folders ???

Hi Experts,

I was struggling to map some folders using below script, I have created a Group Policy and linked it and applied the script in the Log On script.

the script mapping the folders when it's run in locally but it's not mapping anything when it's pushed by the SBS 2008.

when i enable the echo command in the script i can notice that the script is running well (coz the messages showing up)when it's pushed by SBS 2008. but it's not mapping the folders...!

please advice...!


Set objUser = Nothing
Set objAD = Nothing
Set objGroups = Nothing
 
Function getUserGroups(objUser)
 
Set retDict = CreateObject("Scripting.Dictionary")
'Get memberof memberships
If Not IsEmpty(objUser.memberof) Then
        For Each memberOfDN In objUser.GetEx("memberof")
                retDict.Add memberOfDN, memberOfDN
        Next
End If
 
'Query AD for all group objects (used to locate primary group)
Set objConn = CreateObject("ADODB.Connection")
Set objComm =   CreateObject("ADODB.Command")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
Set objComm.ActiveConnection = objConn
objComm.Properties("Page Size") = 1000
objComm.CommandText = "<LDAP://" & objRootDSE.get("defaultNamingContext") & ">;(objectclass=group);distinguishedName,primaryGroupToken;subtree"
Set objRS = objComm.Execute
objRS.MoveFirst
Do 
        If objRS.Fields("primaryGroupToken").Value = objUser.Get("primaryGroupID") Then retDict.Add objRS.Fields(0).Value, objRS.Fields(0).Value
        objRS.MoveNext
Loop Until objRS.EOF
 
Set getUserGroups = retDict
Set retDict = Nothing
Set objRootDSE = Nothing
Set objConn = Nothing
Set objComm = Nothing
Set objRS = Nothing
 
End Function
 
Set objAD = CreateObject("ADSystemInfo")
Set objuser = GetObject("LDAP://" & objAD.UserName)
Set objRootDSE = GetObject("LDAP://RootDSE")
Set objNet = CreateObject("Wscript.Network")
 
Set objGroups = getUserGroups(objUser)
For Each key In objGroups.Keys
        'WScript.Echo objGroups.Item(key)
Next
 
'This is where you test on group membership:
If objGroups.Exists("CN=TEST1,OU=TEST2,OU=TEST3,DC=domain,DC=local") Then
        objNet.MapNetworkDrive "X:", "\\host\shared"
End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of rbrunelle
rbrunelle

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shakthi777

ASKER

didn't got a proper resolution