Cory wrote:
> I am trying to locate a user using LDAP. I may not know what OU the user
> is
> in. A query fails if I try something like:
>
> Set usr = GetObject("CN=Cory Laidlaw,DC=Beyond01,DC=local")
>
> However, if I give it the OU's it works fine. the problem is that I
don't
> want to assume my client will always create the user account in the same
> OU
> (for example, they don't use Small Business Server, which defaults to
the
> OU
> 'SBSUsers'.)
>
> Is there a way to do this? Help! Thanks!!
If you know the sAMAccountName (the "pre-Windows 2000 logon name"), you
can
use the IADsNameTranslate interface to convert this (in combination with
the
NetBIOS name of the domain) to the Distinguished Name (DN). See this link:
http://www.rlmueller.net/NameTranslateFAQ.htm
If you know the Common Name (the value of the cn attribute) you must
search
AD. And, there may be more than one user with the given Common Name (in
different OU's). I use ADO in VBScript programs for this. See this link:
http://www.rlmueller.net/ADOSearchTips.htm
I have an example VBScript program that uses ADO to search for objects
that
have a given Common Name linked here:
http://www.rlmueller.net/Search%20for%20Common%20Name.htm
The program outputs the DN's of all objects that have the given Common
Name.
The link explains how to modify the program to only search for user
objects.
You can also specify the wildcard "*" to find all objects (or users) with
a
given string in their Common Name.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


|