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