2.2 Reading the Root DSE

Reading the root DSE returns information about support of the following features of the LDAP server:

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.

To read the DSE, call the following functions.

  1. Set the LDAP version to LDAP v3 by calling the ldap_set_option function with the option parameter set to LDAP_OPT_PORTOCOL_VERSION and the invalue parameter set to LDAP_VERSION3.

  2. Initialize a session and obtain an LDAP session handle (ld) by calling the ldap_init function.

  3. Establish an authenticated connection by calling the ldap_simple_bind_s function.

  4. Read the DSE by calling the ldap_search_ext_s function. Set the search base to NULL, the search filter to (objectclass=*), and the scope to LDAP_SCOPE_BASE.

  5. Obtain the DSE entry from the results by calling the ldap_first_entry function.

  6. Obtain the first attribute by calling the ldap_first_attribute function.

  7. Obtain the other attributes by calling the ldap_next_attribute function.

  8. Obtain the values for the attributes by calling the ldap_get_values function.

  9. Free the attributes and values by calling the ldap_memfree function.

  10. Free the memory from the search results by calling the ldap_msgfree function.

  11. When you are done with the session handle, call the ldap_unbind function to free the ld and the associated memory.

For sample code, see getdse.c.