Getting the LDAP descriptor from a variable user login name

P

Paolo Debetto

Hi
I have a user's login name obtained with

loginName = CreateObject( "WScript.Network" ).userName

How can i get the LDAP descriptor from this?
I've tried with a query to the ADODB, e.g.


strBase = "<LDAP://dc=myDomain,dc=com>"
strFilter = "(&(objectCategory=person)(objectClass=user)(*********=" &
loginName & "))"
strAttributes = "distinguishedName,cn"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"

Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection

objCommand.CommandText = strQuery
Set objRecordSet = objCommand.Execute



It works, but I don't know what to put instead of **********...

Thanks in advance
 
R

Richard Mueller

Hi,

You are asking for the attribute name (in the schema, it is called the
ldapDisplayName of the attribute). In this case the attribute is
sAMAccountName. Use:

(&(objectCategory=person)(objectClass=user(sAMAccountName=" & loginName &
"))"
 
P

Paolo Debetto

Thanks a lot Richard I think you are the single best source of info on
active directory in the whole internet...

Paolo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top