WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Examples for ADSI not working


Question

I have looked at quite a few of the examples in the help files and tried to change them to fit my environment, and none of them seem to be working.

I keep getting error 1063: object doesn't exist, on my own user account. For example, this does not run for me.

AddExtender("wwads34i.dll")
; Set credentials.
dsSetCredent("adminacct", "********")

;  An Active Directory example.
; The user object "Russ T Gate" on the "win2000" server.
; Make sure the following on one line
sAdsiPath = "LDAP://myserver/CN=rgate,CN=Users,DC=myserver,DC=bpk1,DC=com"

; Test if object is a container.
if dsIsContainer(sAdsiPath) 
   message("Container Check", "It is a container")
else
   message("Container Check", "It is NOT a container")
   exit
endif

Answer

There are many possible explanations. First, you need to verify that you have a network connect to the domain containing your server. This is easily done by attempting to browse the the server using Explorer (My Network Places on XP). Secondly, you need to determine the exact ADSI path to the object of interest. You can do this by using the Administrative tools on the server to view the object and its path. Another approach is to use serverless binding with "LDAP://RootDSE" Here is a script fragment that uses this technique to find a user path:
; samAccountName of user of interest
AddExtender("wwads34i.dll")
MyUser = "rgate"

ServerDn=dsGetProperty("LDAP://rootDSE", "serverName")
ServerName=ItemExtract(1, ServerDn, ",")
ServerName=ItemExtract(2, ServerName, "=")
ServerDn=dsGetProperty("LDAP://rootDSE", "defaultNamingContext")
ServerPath="LDAP://%ServerName%/%ServerDN%"
UserPath=dsFindPath(ServerPath, "(&(objectCategory=person)(sAMAccountName=%MyUser%))")
There are other possibilities involving firewalls, ports, OS version and group policy to name a few but give this a try first.
Article ID:   W15809
File Created: 2004:03:30:15:40:58
Last Updated: 2004:03:30:15:40:58