3

can someone explain the makeup of the ldap string parts.

the one i have is:

string strSQL = "SELECT mail FROM 'LDAP://DC=amrs,DC=win,DC=ml,dc=COM' WHERE samaccountname = '" + UserName.Replace(@"AMRS\", "") + "'";

this gets an email for a particular username. now i need to get other info from an ldap query and fail to get the setting correct and also i have no clue what the values are in the ldap settings. "LDAP://DC=amrs,DC=win,DC=ml,dc=COM"

can anyone explain this to me please?

kacalapy
  • 9,806
  • 20
  • 74
  • 119
  • I don't know if this will help or not http://www.petri.co.il/ldap_search_samples_for_windows_2003_and_exchange.htm – johnny Dec 01 '10 at 15:18

3 Answers3

16

The DC= prefix in the LDAP string stands for domain component (dc). These are the parts that make up the domain of your LDAP server. Those are fixed and need to be used for any object on that server.

In "DNS style", this would read: (something).amrs.win.ml.com (e.g. a server name, machine name etc.)

Richard Mueller has a great post explaining the most commonly found prefixes in LDAP bind strings - stuff like dc=, ou= (organizational unit) or cn= (common name).

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
0

It depends on your particular LDAP schema. Try an LDAP browser like JXplorer to find out how your Schema is structured. It's also great for trying out queries like this.

DC is short for Domain Component. The LDAP: URL describes a subtree on your particular server. Your where clause queries the entries for the attribute samaccountname for that match.

Captain Giraffe
  • 14,407
  • 6
  • 39
  • 67
0

You are simply issuing a query to the LDAP server. Like anything else out there it has its own format for querying it. I wouldn't call it a language but it certainly must be formatted correctly. You need to find a basic tutorial on LDAP and the components that can be looked up in your LDAP directory, like for Windows. You can also look at items like this:

Active Directory LDAP Query by sAMAccountName and Domain

to see how things are done and learn by example. For me, it's a little like regular expressions though not near as cryptic, I have to look it up every time if I need something but at least I can recognize parts when I see it, like on DC, I may have dc=mydomain,dc=org. I know by looking that is my top level where I start my query. From there I have to look it up.

Community
  • 1
  • 1
johnny
  • 19,272
  • 52
  • 157
  • 259