]> git.sur5r.net Git - openldap/blob - doc/man/man3/ldap_get_dn.3
Update man pages based upon required use of ldap_memfree() instead of free()
[openldap] / doc / man / man3 / ldap_get_dn.3
1 .TH LDAP_GET_DN 3 "22 September 1998" "OpenLDAP LDVERSION"
2 .SH NAME
3 ldap_get_dn, ldap_explode_dn, ldap_explode_rdn, ldap_dn2ufn, ldap_is_dns_dn, ldap_explode_dns \- LDAP DN handling routines
4 .SH SYNOPSIS
5 .nf
6 .ft B
7 #include <lber.h>
8 #include <ldap.h>
9 .LP
10 .ft B
11 char *ldap_get_dn(ld, entry)
12 .ft
13 LDAP *ld;
14 LDAPMessage *entry;
15 .LP
16 .ft B
17 char **ldap_explode_dn(dn, notypes)
18 .ft
19 char *dn;
20 int notypes;
21 .LP
22 .ft B
23 char **ldap_explode_rdn(rdn, notypes)
24 .ft
25 char *rdn;
26 int notypes;
27 .LP
28 .ft B
29 char *ldap_dn2ufn(dn)
30 .ft
31 char *dn;
32 .LP
33 .ft B
34 int ldap_is_dns_dn(dn)
35 .ft
36 char *dn;
37 .LP
38 .ft B
39 char **ldap_explode_dns(dn)
40 .ft
41 char *dn;
42 .SH DESCRIPTION
43 These routines allow LDAP entry names (Distinguished Names, or DNs)
44 to be obtained, parsed, converted to a user-friendly form, and tested.
45 A DN has the form described in RFC 1779 "A String Representation of
46 Distinguished Names", unless it is an experimental DNS-style DN
47 which takes the form of an RFC 822 mail address.
48 .LP
49 The
50 .B ldap_get_dn()
51 routine takes an \fIentry\fP as returned by
52 .BR ldap_first_entry (3)
53 or
54 .BR ldap_next_entry (3)
55 and returns a copy of
56 the entry's DN.  Space for the DN will be obtained dynamically
57 and should be freed by the caller using 
58 .BR ldap_memfree (3).
59 .LP
60 The
61 .B ldap_explode_dn()
62 routine takes a DN as returned by
63 .B ldap_get_dn()
64 and breaks it up into its component parts.  Each part is known as a
65 Relative Distinguished Name, or RDN.
66 .B ldap_explode_dn()
67 returns a
68 NULL-terminated array, each component of which contains an RDN from the
69 DN.  The \fInotypes\fP parameter is used to request that only the RDN
70 values be returned, not their types.  For example, the DN "cn=Bob,
71 c=US" would return as either { "cn=Bob", "c=US", NULL } or { "Bob",
72 "US", NULL }, depending on whether notypes was 0 or 1, respectively.
73 The result can be freed by calling
74 .BR ldap_value_free (3).
75 .LP
76 Similarly, the
77 .B ldap_explode_rdn()
78 routine takes an RDN as returned by
79 .B ldap_explode_dn(dn,0)
80 and breaks it up into its "type=value" component parts (or just "value",
81 if the \fInotypes\fP parameter is set).  The result can be freed by
82 calling
83 .BR ldap_value_free (3).
84 .LP
85 .B ldap_dn2ufn()
86 is used to turn a DN as returned by
87 .B ldap_get_dn()
88 into a more user-friendly form, stripping off type names.  See
89 RFC 1781 "Using the Directory to Achieve User Friendly Naming"
90 for more details on the UFN format.  The space for the UFN returned
91 is obtained dynamically and the user is responsible for freeing it
92 via a call to
93 .BR ldap_memfree (3).
94 .LP
95 .B ldap_is_dns_dn()
96 returns non-zero if the dn string is an experimental
97 DNS-style DN (generally in the form of an RFC 822 e-mail address).  It
98 returns zero if the dn appears to be an RFC 1779 format DN.
99 .LP
100 .B ldap_explode_dns()
101 takes a DNS-style DN and breaks it up into its
102 component parts.
103 .B ldap_explode_dns()
104 returns a NULL-terminated array.
105 For example, the DN "mcs.umich.edu" will return { "mcs", "umich", "edu",
106 NULL }.  The result can be freed by calling
107 .BR ldap_value_free (3).
108 .SH ERRORS
109 If an error occurs in
110 .BR ldap_get_dn() ,
111 NULL is returned and the
112 .B ld_errno
113 field in the \fIld\fP parameter is set to indicate the error.  See
114 .BR ldap_error (3)
115 for a description of possible error codes.
116 .BR ldap_explode_dn() ,
117 .BR ldap_explode_rdn() ,
118 .B ldap_explode_dns()
119 and
120 .B ldap_dn2ufn()
121 will return NULL with
122 .BR errno (3)
123 set appropriately in case of trouble.
124 .SH NOTES
125 These routines dyanamically allocate memory that the caller must free.
126 .SH SEE ALSO
127 .BR ldap(3),
128 .BR ldap_error(3),
129 .BR ldap_first_entry(3),
130 .BR ldap_memfree(3),
131 .BR ldap_value_free(3)
132 .SH ACKNOWLEDGEMENTS
133 .B      OpenLDAP
134 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
135 .B      OpenLDAP
136 is derived from University of Michigan LDAP 3.3 Release.