1 .TH LDAP_GET_DN 3 "2008/07/16" "OpenLDAP 2.4.11"
2 .\" $OpenLDAP: pkg/ldap/doc/man/man3/ldap_get_dn.3,v 1.28.2.4 2008/02/11 23:26:39 kurt Exp $
3 .\" Copyright 1998-2008 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
6 ldap_get_dn, ldap_explode_dn, ldap_explode_rdn, ldap_dn2ufn \- LDAP DN handling routines
8 OpenLDAP LDAP (libldap, -lldap)
15 char *ldap_get_dn( LDAP *ld, LDAPMessage *entry )
18 int ldap_str2dn( const char *str, LDAPDN **dn, unsigned flags )
21 int ldap_dn2str( LDAPDN *dn, char **str, unsigned flags )
24 char **ldap_explode_dn( const char *dn, int notypes )
27 char **ldap_explode_rdn( const char *rdn, int notypes )
30 char *ldap_dn2ufn( const char * dn )
33 char *ldap_dn2dcedn( const char * dn )
36 char *ldap_dcedn2dn( const char * dn )
39 char *ldap_dn2ad_canonical( const char * dn )
41 These routines allow LDAP entry names (Distinguished Names, or DNs)
42 to be obtained, parsed, converted to a user-friendly form, and tested.
43 A DN has the form described in
44 RFC 4414 "Lightweight Directory Access Protocol (LDAP):
45 String Representation of Distinguished Names".
49 routine takes an \fIentry\fP as returned by
50 .BR ldap_first_entry (3)
52 .BR ldap_next_entry (3)
54 the entry's DN. Space for the DN will be obtained dynamically
55 and should be freed by the caller using
59 parses a string representation of a distinguished name contained in
66 structures, arranged in
75 typedef struct ldap_ava {
77 struct berval *la_value;
81 typedef LDAPAVA** LDAPRDN;
82 typedef LDAPRDN** LDAPDN;
86 The attribute types and the attribute values are not normalized.
93 the latter meaning that the value is BER/DER encoded and thus must
94 be represented as, quoting from RFC 4514, " ... an
95 octothorpe character ('#' ASCII 35) followed by the hexadecimal
96 representation of each of the bytes of the BER encoding of the X.500
105 LDAP_DN_FORMAT_LDAPV3
106 LDAP_DN_FORMAT_LDAPV2
110 which defines what DN syntax is expected (according to RFC 4514,
111 RFC 1779 and DCE, respectively).
112 The format can be \fIOR\fPed to the flags
116 LDAP_DN_P_NO_SPACE_AFTER_RDN
121 The latter is a shortcut for all the previous limitations.
123 .B LDAP_DN_P_NO_SPACES
124 does not allow extra spaces in the dn; the default is to silently
125 eliminate spaces around AVA separators ('='), RDN component separators
126 ('+' for LDAPv3/LDAPv2 or ',' for DCE) and RDN separators
127 (',' LDAPv3/LDAPv2 or '/' for DCE).
129 .B LDAP_DN_P_NO_SPACE_AFTER_RDN
130 does not allow a single space after RDN separators.
133 performs the inverse operation, yielding in
135 a string representation of
137 It allows the same values for
145 LDAP_DN_FORMAT_AD_CANONICAL
148 for user-friendly naming (RFC 1781) and AD canonical.
150 The following routines are viewed as deprecated in favor of
154 They are provided to support legacy applications.
158 routine takes a DN as returned by
160 and breaks it up into its component parts. Each part is known as a
161 Relative Distinguished Name, or RDN.
164 NULL-terminated array, each component of which contains an RDN from the
165 DN. The \fInotypes\fP parameter is used to request that only the RDN
166 values be returned, not their types. For example, the DN "cn=Bob,
167 c=US" would return as either { "cn=Bob", "c=US", NULL } or { "Bob",
168 "US", NULL }, depending on whether notypes was 0 or 1, respectively.
169 Assertion values in RDN strings may included escaped characters.
170 The result can be freed by calling
171 .BR ldap_value_free (3).
174 .B ldap_explode_rdn()
175 routine takes an RDN as returned by
176 .B ldap_explode_dn(dn,0)
177 and breaks it up into its "type=value" component parts (or just "value",
178 if the \fInotypes\fP parameter is set). Note the value is not
179 unescaped. The result can be freed by calling
180 .BR ldap_value_free (3).
183 is used to turn a DN as returned by
185 into a more user-friendly form, stripping off all type names. See
186 "Using the Directory to Achieve User Friendly Naming" (RFC 1781)
187 for more details on the UFN format. Due to the ambiguous nature
188 of the format, it is generally only used for display purposes.
189 The space for the UFN returned is obtained dynamically and the user
190 is responsible for freeing it via a call to
191 .BR ldap_memfree (3).
194 is used to turn a DN as returned by
196 into a DCE-style DN, e.g. a string with most-significant to least
197 significant rdns separated by slashes ('/'); rdn components
198 are separated by commas (',').
199 Only printable chars (e.g. LDAPv2 printable string) are allowed,
200 at least in this implementation.
202 performs the opposite operation.
203 .B ldap_dn2ad_canonical()
204 turns a DN into a AD canonical name, which is basically a DCE dn
205 with attribute types omitted.
206 The trailing domain, if present, is turned in a DNS-like domain.
207 The space for the returned value is obtained dynamically and the user
208 is responsible for freeing it via a call to
209 .BR ldap_memfree (3).
211 If an error occurs in
213 NULL is returned and the
215 field in the \fIld\fP parameter is set to indicate the error. See
217 for a description of possible error codes.
218 .BR ldap_explode_dn() ,
219 .BR ldap_explode_rdn() ,
224 .B ldap_dn2ad_canonical()
225 will return NULL with
227 set appropriately in case of trouble.
229 These routines dynamically allocate memory that the caller must free.
233 .BR ldap_first_entry (3),
234 .BR ldap_memfree (3),
235 .BR ldap_value_free (3)
237 .\" Shared Project Acknowledgement Text
238 .B "OpenLDAP Software"
239 is developed and maintained by The OpenLDAP Project <http://www.openldap.org/>.
240 .B "OpenLDAP Software"
241 is derived from University of Michigan LDAP 3.3 Release.