How do you do a query of an LDAP store by sAMAccountName and Domain? What is the "domain" property named in Active Directory or LDAP terms?
This is what I have for the filter so far. I'd like to be able to add in the domain:
(&(objectCategory=Person)(sAMAccountName=BTYNDALL))
sAMAccountName is the ldap attribute that should match the login name. dn is the distinguished name returned by the LDAP server that matches sAMAccountName. jsmith is the login id of the user logging into Vertica.
First, modify your search filter to only look for users and not contacts:
(&(objectCategory=person)(objectClass=user)(sAMAccountName=BTYNDALL))
You can enumerate all of the domains of a forest by connecting to the configuration partition and enumerating all the entries in the partitions container. Sorry I don't have any C# code right now but here is some vbscript code I've used in the past:
Set objRootDSE = GetObject("LDAP://RootDSE") AdComm.Properties("Sort on") = "name" AdComm.CommandText = "<LDAP://cn=Partitions," & _ objRootDSE.Get("ConfigurationNamingContext") & ">;" & _ "(&(objectcategory=crossRef)(systemFlags=3));" & _ "name,nCName,dnsRoot;onelevel" set AdRs = AdComm.Execute
From that you can retrieve the name and dnsRoot of each partition:
AdRs.MoveFirst With AdRs While Not .EOF dnsRoot = .Fields("dnsRoot") Set objOption = Document.createElement("OPTION") objOption.Text = dnsRoot(0) objOption.Value = "LDAP://" & dnsRoot(0) & "/" & .Fields("nCName").Value Domain.Add(objOption) .MoveNext Wend End With
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With