David wrote:
>I am just starting to work with windows scripting and ADSI, and trying some
> of the examples found in the TechNet doucumentation.
> Here is my script:
> Set objUser = GetObject("LDAP://cn=david,dc=ectax,dc=escambia")
> ectax.escambia the domain and david being a user account in the AD.
> and error:
> getdomainuser.vbs(1, 1) (null): There is no such object on the server.
> The sample code in the doc also includes an OU parameter. in our case
> there
> are no OU's under the domain so that was left out of my getobject
> statement.
> I can remove the cn parameter and the object for the domain is created
> with
> no errors.
You need to find the correct binding string to bind to the user object. The
binding string you used above assumes that the object with Common Name
"david" is in the root of the domain ectax.escambia, which is not likely. If
you have no Organizational Units, then most likely your user objects are in
the default container, "cn=Users". You might try:
Set objUser = GetObject("LDAP://cn=david,cn=users,dc=ectax,dc=escambia")
It is also possible that "david" is the "pre-Windows 2000 logon" name of the
user, but the Common Name is something else. To get used to the
Distinguished Names in your domain it might help to run a script that dumps
out the names of all user's. The binding string you need to bind to the user
object is the Distinguished Name, plus the moniker "LDAP://". For example,
if all of your users are in the "cn=Users" container, you could run the
following (at a command prompt):
=======
' Bind to cn=Users container.
Set objContainer = GetObject("LDAP://cn=Users,dc=ectax,dc=escambia")
' Filter on user objects.
objContainer.Filter = Array("user")
' Enumerate all user objects in the container.
For Each objUser In objContainer
Wscript.Echo objUser.distingishedName
Next
====
Or, if you have OU's and containers you can run a VBScript program that uses
ADO to query for all users and output their Distinguished Names. The example
linked below creates a text file with the Distinguished Names of all users
in the domain:
http://www.rlmueller.net/Create%20User%20List%202.htm
You pass the name of the file as a parameter to the program and it creates
the file with the names. Alternatively, if you have a Domain Controller with
Windows Server 2003 or above, you can use the dsquery utility to dump out
the Distinguished Names of all users. At a command prompt on the DC use:
dsquery user
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--