Reading the Root DSE returns information about support of the following features of the LDAP server:
LDAP versions (v2 and v3)
LDAP controls and extensions
Schema object name
With the schema name, you can then extend the schema or read its definitions. You must establish an LDAP v3 connection to read the DSE.
Reading the Root DSE requires the following steps:
Set the search base to an empty string.
Set the search filter to objectclass=*
Set the search scope to LDAP_SCOPE_BASE.
The following example demonstrates these procedures. For a complete sample, see GetDSE.java in the Sample Code.
Initially the LDAP version needs to be set and connect to the LDAP server.
int ldapVersion = LDAPConnection.LDAP_V3; LDAPConnection lc = new LDAPConnection(); lc.connect(LDAP Host, ldapPort); lc.bind(ldapVersion, loginDN, password);
Next, we need to set the search base, filter, and scope.
LDAPSearchResults searchResults = lc.search( "",
LDAPConnection.SCOPE_BASE,
"(objectclass=*)",
returnedAttributes,
attributeOnly);
This search returns one entry which will be the root DSE.