"Cory J. Laidlaw, Beyond01.com"
<CoryJLaidlawBeyond01com@[EMAIL PROTECTED]
> wrote in message
news:0824B264-FB8F-45ED-99C7-4CBED1D75B54@[EMAIL PROTECTED]
> Howdy!
>
> i am trying to search LDAP from an Access 2003 module. I want to return
> the
> username on an account from a SAMAccountname.
>
> The following code works: It returns the SAMAccountName (coryL) from
LDAP
> when using the Username:
>
> Public Sub test()
>
> Set AdUsr = GetObject("LDAP://CN=Cory
> Laidlaw,OU=SBSUsers,OU=Users,OU=MyBusiness,DC=Beyond01,DC=local")
> Debug.Print AdUsr.samaccountname
>
>
> End Sub
>
> However, trying the reverse fails, as in this code, it returns "There is
> no
> such object on the server"
>
> Public Sub testfails()
>
> Set AdUsr =
>
GetObject("LDAP://CN=CoryL,OU=SBSUsers,OU=Users,OU=MyBusiness,DC=Beyond01,DC=local")
> Debug.Print AdUsr.UserName
>
> End Sub
>
> Can anyone help me see where I am going astray? thanks much!
Give the sAMAccountName I know of two methods to retrieve the
Distinguished
Name (and thus the Common Name). One is to use the IADsNameTranslate
interface. The other is to search AD for the object, perhaps with ADO.
For information on using NameTranslate in VB or VBScript see this link:
http://www.rlmueller.net/NameTranslateFAQ.htm
A quick example, where the NetBIOS name of the domain is known (and hard
coded) is in # 6 of the FAQ. You can also retrieve the domain name
programmatically. Using ADO to find the object that has a give value for
sAMAccountName is explained in this link:
http://www.rlmueller.net/ADOSearchTips.htm
NameTranslate is more efficient in this case.


|