Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: Retrieve user attributes by SamAccountName

HTVi
TV Discussion Newsgroups

Retrieve user attributes by SamAccountName
dzschomler 5/23/2007 3:02:10 PM
Can anyone tell me how I can access user attributes (FullName, CN, Mail,
Manager, Domain Controler, etc) by querying SamAccountName rather than CN?

I.E. Instead of doing:
'Set objuser = GetObject("LDAP://cn=Dan
Zschomler,ou=Users,ou=Durham,ou=sites,dc=americasdc=Local")

Is there a way to do:
'Set objuser =
GetObject("LDAP://SamAccountName=dzschomler,ou=Users,ou=Durham,ou=sites,dc=americas,dc=Local")
RE: Retrieve user attributes by SamAccountName
dzschomler 5/23/2007 3:38:02 PM
I found the information I needed:

strQuery = "<LDAP://dc=MyDomain,dc=com>;(sAMAccountName=" & strNTName &
");distinguishedName;subtree"


"dzschomler" wrote:

[Quoted Text]
> Can anyone tell me how I can access user attributes (FullName, CN, Mail,
> Manager, Domain Controler, etc) by querying SamAccountName rather than CN?
>
> I.E. Instead of doing:
> 'Set objuser = GetObject("LDAP://cn=Dan
> Zschomler,ou=Users,ou=Durham,ou=sites,dc=americasdc=Local")
>
> Is there a way to do:
> 'Set objuser =
> GetObject("LDAP://SamAccountName=dzschomler,ou=Users,ou=Durham,ou=sites,dc=americas,dc=Local")
Re: Retrieve user attributes by SamAccountName
"Richard Mueller [MVP]" <rlmueller-nospam[ at ]ameritech.nospam.net> 5/23/2007 4:10:40 PM
I use the NameTranslate object. This converts the NT name of the object (the
value of the sAMAccountName attribute), plus the NetBIOS name of the domain,
to the Distinguished Name. See this link:

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

As you suggest, you can also query AD for the object with the given
sAMAccountName. In a script you would use ADO to run the query. However,
NameTranslate should be more efficient.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

"dzschomler" <dzschomler[ at ]discussions.microsoft.com> wrote in message
news:FF307FD9-43A7-4E6D-8ADD-3E2D1883E223[ at ]microsoft.com...
[Quoted Text]
>I found the information I needed:
>
> strQuery = "<LDAP://dc=MyDomain,dc=com>;(sAMAccountName=" & strNTName &
> ");distinguishedName;subtree"
>
>
> "dzschomler" wrote:
>
>> Can anyone tell me how I can access user attributes (FullName, CN, Mail,
>> Manager, Domain Controler, etc) by querying SamAccountName rather than
>> CN?
>>
>> I.E. Instead of doing:
>> 'Set objuser = GetObject("LDAP://cn=Dan
>> Zschomler,ou=Users,ou=Durham,ou=sites,dc=americasdc=Local")
>>
>> Is there a way to do:
>> 'Set objuser =
>> GetObject("LDAP://SamAccountName=dzschomler,ou=Users,ou=Durham,ou=sites,dc=americas,dc=Local")


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen