Talk About Network

Google





Software > ADSI General > Re: Searching L...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 5339 of 5437
Post > Topic >>

Re: Searching LDAP by SamAccountName

by "Richard Mueller [MVP]" <rlmueller-nospam@[EMAIL PROTECTED] > Jul 24, 2008 at 01:03 PM

"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.
 




 3 Posts in Topic:
Searching LDAP by SamAccountName
=?Utf-8?B?Q29yeSBKLiBMYWl  2008-07-24 10:05:00 
Re: Searching LDAP by SamAccountName
"Richard Mueller [MV  2008-07-24 13:03:41 
Re: Searching LDAP by SamAccountName
=?Utf-8?B?Q29yeSBKLiBMYWl  2008-07-25 07:22:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Thu Jan 8 20:49:16 PST 2009.