I am connected to LDAP, but I don’t know anything about the structure of it. How can I find out what baseDn is ?
final NamingEnumeration<SearchResult> result = context.search(
"", "(objectClass=organizationalUnits)", controls);
tried this, but nothing returns
Filip Klokočník is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
How can I find out what baseDn is ?
Normally it should have been given to you together with the other connection details.
Usually you can get it from the “rootDSE” entry; some LDAP libraries have a specific function to retrieve it, but you can always get it using a search operation:
-
Search base:
""
(empty DN) -
Search scope:
BASE
(this is important – SUB won’t retrieve the rootDSE entry) -
Search filter:
(objectClass=*)
-
Requested attributes: either
{"namingContexts"}
or{"*", "+"}
(many servers have it as an ‘operational’ attribute, hidden by default)
The result entry will have a namingContexts
attribute where each value specifies a valid base DN on that server. However, don’t make this lookup every single time – generally the base DN is meant to be part of the static configuration.