We help IT Professionals succeed at work.
Get Started

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

428 Views
Last Modified: 2013-12-26
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

Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 3 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE