Saturday, January 20, 2007 1:24 AM dbottjer

ADSystemInfo Object Failing

Hacking my work laptop seems to be a regular occurrence lately.  Like most enterprises ours applies active directory policies that affect our machines.  Some policies make testing beta versions and new releases of software ahead of the official rollouts difficult.

 

After logging into the corporate network, over VPN, I noticed my login scripts weren’t running like they usually do.  Normally, after a successful connection a message box displays a welcome message. 

 

Curiosity got the best of me so I ran the script manually and began debugging.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Option Explicit

Dim Shell, netSys



Set Shell = WScript.CreateObject("WScript.Shell")

Set netSys = WScript.CreateObject("WScript.Network")



Dim strUsrDomain

Dim oInfo, LDAPUsr



strUsrDomain=netSys.UserDomain



' Some machines have had problems accessing Active Directory information so these section

' captures any errors and stops the script if there are any

Set oInfo = CreateObject("ADSystemInfo")

If err.number <> 0 Then

shell.popup("Error creating oInfo object " & e.description)

WScript.quit(1)

End If

Set LDAPUsr = GetObject("LDAP://" & oInfo.UserName)

If err.number <> 0 Then

shell.popup("Error creating LDAPUsr object " & e.description)

WScript.quit(1)

End If
 

The script was failing while trying to get the username from the oInfo object (oInfo.Username line: 20).  I began wondering if the problem was a permissions issue.  To test my theory I set gave my network login read access to the following DLL’s:

 

AdsLocator.dll

Activeds.dll

 

Finally, I tried running the login script again and it work perfectly.

Filed under: ,

Comments

No Comments