Re: There is no such object on the server



Joe wrote:

I'm trying to write a script that will get me info on a user account.
But I'm having a problem with GetObject. Below is my entire script (2
lines), yes I know it doesn't do much. I'm just trying to figure out
what the problem is.
------
Set objUser = GetObject ("LDAP://
cn=username,ou=city,ou=users,dc=corp,dc=acme,dc=local")
Wscript.Echo "Password last changed: " & objUser.passwordLastChanged
------

I get a Windows Script Host error
Line: 1
Char: 1
Error: There is no such object on the server
Code: 80072030
Source: (null)

The username is spelled correctly. I have an OU for each city with an
office, and in each one there is another OU called "users". I tried
it both ways, ou=city,ou=users and ou=users,ou=city. Everything is
spelled correctly. What is the problem? Is it case sensitive, am I
missing a field, am I missing a space, what?


The ADsPath is not case sensitive. The domain components in the
Distinguished Name should be listed from left to right from the lowest level
(child) to the highest level in the AD hierarchy. In your example the object
with common name "username" resides in the ou "city", which in turn resides
in the ou "users", which is in the root of the domain "corp.acme.local".

The error indicates the object was not found. A possibility is that you
specified the "pre-Windows 2000 logon name" (also called the NT name)
instead of the Common Name. The Common Name is shown in ADUC in a field
labeled "Name". The "pre-Windows 2000 logon name" is on the "Account" tab in
ADUC. Sometimes the common name matches the NT name, but it often does not.
You can figure out the Distinguished Name in ADUC by viewing the field
labeled "Fully qualified domain name of object" on the "Object" tab, but the
components are listed in reverse order, without the "ou=", "dc=", and "cn="
monikers, and with slashes instead of commas separating the components.

Sometimes the "pre-Windows 2000 logon name" is called the username or logon
name or userid. If this is all you know, you can use the NameTranslate
object to convert to the Distinguished Name. See this link for details:

http://www.rlmueller.net/NameTranslateFAQ.htm

Otherwise in ADUC use the value in the "Name" field. You can use ADSI Edit
to view the distinguishedName attribute of the user object, which is the
value required when you bind with the LDAP provider. If the user is the
current user, you can retrieve the value of the distinguishedName attribute
from the ADSystemInfo object. For example:
============
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName
Set objUser = GetObject("LDAP://"; & strUserDN)

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Error Message when running script
    ... The Common Name of any object does not uniquely identify the object. ... Microsoft MVP Scripting and ADSI ... Is there a code I can add to the script that when run, ... Edit to browse objects and their properties, such as distinguishedName. ...
    (microsoft.public.windows.server.scripting)
  • Re: nt4 domain to W2k3 AD
    ... original server. ... each user must have a Common Name (the value ... In ADUC this name is on the Account tab ... Each user object has a distinguishedName attribute, ...
    (microsoft.public.windows.server.active_directory)
  • Re: Moving Multiple users from many differnt OUs at once
    ... names are NT Names (or the NT Name values are always the same as the Common ... ' Specify the NetBIOS name of the domain and the NT name of the user. ... If "Test Accnt1" is the common name, then we have to use ADO to search AD ... will be cn, sAMAccountName, or distinguishedName. ...
    (microsoft.public.windows.server.scripting)
  • Re: Moving user to another container
    ... The script looks ok to me. ... ' Constants for the NameTranslate object. ... ' Use the Set method to specify the RPC 1779 format of the domain name. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Scripting ADSI and Sub Domains Question
    ... Your script used ADO to retrieve the distinguishedName, ... bind to the object and retrieve memberOf. ... Sub Window_onLoad ...
    (microsoft.public.windows.server.scripting)