Show Table of Contents
5.6. Working with DNs and RDNs
In certain situations, the frontend passes DNs to the backend through the parameter block. For example, when calling the
add function, the parameter block includes a parameter that specifies the DN of the new entry to be added.
If you need to manipulate DNs within parameter blocks, you can call the following frontend routines:
Table 5.2. Frontend Functions for Manipulating DNs
| Function | Description |
|---|---|
| slapi_dn_isroot() | Determines if a DN is the root DN (the DN of the privileged superuser). |
| Gets a copy of the parent DN. | |
| slapi_sdn_issuffix() | Checks if a Slapi_DN structure is the child of another suffix. |
| slapi_be_issuffix() | Determines if a DN is a suffix served by one of the server's backends. |
| slapi_sdn_get_ndn() | Normalizes a DN. |
| slapi_dn_normalize_case() | Normalizes a DN and converts all characters to lowercase. |
5.6.1. Determining If a DN Is the Root DN
To determine if a DN is the root DN, call slapi_dn_isroot(). This function returns 1 if the specified DN is the root DN of the local database. It returns 0 if the DN is not the root DN.
5.6.2. Working with DN Suffixes
A suffix of a DN identifies a subtree in the directory tree where the DN is located. For example, consider the following DN:
cn=Babs Jensen,ou=Product Development,l=US, dc=example,dc=com
In this case, one of the suffixes is:
l=US, dc=example,dc=com
This suffix indicates that the Babs Jensen entry is located in the Example Corporation subtree in the directory tree.
To determine if a value is a suffix for a DN, call slapi_sdn_issuffix(). To determine if a DN is one of the suffixes served by the backend, call the slapi_be_issuffix() function.
For more information on suffixes and backend configuration, see the Administration Guide.
5.6.3. Getting the Parent DN of a DN
To get a copy of the parent DN for a DN, call either the slapi_sdn_get_parent() or the slapi_sdn_get_backend_parent() function.
These functions return the parent DN of
dn. If dn is a suffix served by the backend, slapi_sdn_get_backend_parent() returns NULL.
When you are finished working with the parent DN, you should free it from memory by calling slapi_ch_free_string().
5.6.4. Normalizing a DN
You can use the following frontend functions to normalize and convert the case of a DN:
- Use slapi_sdn_get_ndn() to normalize a DN.
- Use slapi_dn_normalize_case() to both normalize the DN and convert all characters in the DN to lowercase.
Note
These functions operate on the actual DN specified in the argument, not a copy of the DN. If you want to modify a copy of the DN, call slapi_ch_strdup() to make a copy of the DN.
To compare DNs (for example, to search the database for a particular DN), use the slapi_sdn_compare() function instead of normalizing and comparing the DNs using string functions.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.