LDAP Library Functions ldapgetdn(3LDAP)
NAME
ldapgetdn, ldapexplodedn, ldapdn2ufn, ldapisdnsdn,
ldapexplodedns, ldapdnstodn - LDAP DN handling func-
tions
SYNOPSIS
cc[ flag... ] file... -lldap[ library... ]
#include
#include
char *ldapgetdn(LDAP *ld, LDAPMessage *entry);
char **ldapexplodedn(char *dn, int notypes);
char *ldapdn2ufn(char *dn);
int ldapisdnsdn(char *dn);
char **ldapexplodedns(char *dn);
char *ldapdnstodn(char *dnsname, int *nameparts);
DESCRIPTION
These functions allow LDAP entry names (Distinguished Names,
or DNs) to be obtained, parsed, converted to a user-friendly
form, and tested. A DN has the form described in RFC 1779 A
String Representation of Distinguished Names, unless it is
an experimental DNS-style DN which takes the form of an RFC
822 mail address.
The ldapgetdn() function takes an entry as returned by
ldapfirstentry(3LDAP) or ldapnextentry(3LDAP) and
returns a copy of the entry's DN. Space for the DN will
have been obtained by means of malloc(3C), and should be
freed by the caller by a call to free(3C).
The ldapexplodedn() function takes a DN as returned by
ldapgetdn() and breaks it up into its component parts.
Each part is known as a Relative Distinguished Name, or RDN.
ldapexplodedn() returns a null-terminated array, each com-
ponent of which contains an RDN from the DN. The notypes
parameter is used to request that only the RDN values be
returned, not their types. For example, the DN "cn=Bob,
c=US" would return as either { "cn=Bob", "c=US", NUL } or {
SunOS 5.11 Last change: 27 Jan 2002 1
LDAP Library Functions ldapgetdn(3LDAP)
"Bob", "US", NUL }, depending on whether notypes was 0 or
1, respectively. The result can be freed by calling
ldapvaluefree(3LDAP).
ldapdn2ufn() is used to turn a DN as returned by
ldapgetdn() into a more user-friendly form, stripping off
type names. See RFC 1781 "Using the Directory to Achieve
User Friendly Naming" for more details on the UFN format.
The space for the UFN returned is obtained by a call to
malloc(3C), and the user is responsible for freeing it by
means of a call to free(3C).
ldapisdnsdn() returns non-zero if the dn string is an
experimental DNS-style DN (generally in the form of an RFC
822 e-mail address). It returns zero if the dn appears to
be an RFC 1779 format DN.
ldapexplodedns() takes a DNS-style DN and breaks it up
into its component parts. ldapexplodedns() returns a
null-terminated array. For example, the DN "mcs.umich.edu"
will return { "mcs", "umich", "edu", NUL }. The result can
be freed by calling ldapvaluefree(3LDAP).
ldapdnstodn() converts a DNS domain name into an X.500
distinguished name. A string distinguished name and the
number of nameparts is returned.
ERORS
If an error occurs in ldapgetdn(), NUL is returned and
the lderrno field in the ld parameter is set to indicate
the error. See ldaperror(3LDAP) for a description of pos-
sible error codes. ldapexplodedn(), ldapexplodedns() and
ldapdn2ufn() will return NUL with errno(3C) set appropri-
ately in case of trouble.
If an error in ldapdnstodn() is encountered zero is
returned. The caller should free the returned string if it
is non-zero.
ATRIBUTES
See attributes(5) for a description of the following attri-
butes:
SunOS 5.11 Last change: 27 Jan 2002 2
LDAP Library Functions ldapgetdn(3LDAP)
ATRIBUTE TYPE ATRIBUTE VALUE
Availability SUNWcsl (32-bit)
SUNWcslx (64-bit)
Interface Stability Evolving
SEE ALSO
ldap(3LDAP), ldapfirstentry(3LDAP), ldaperror(3LDAP),
ldapvaluefree(3LDAP)
NOTES
These functions allocate memory that the caller must free.
SunOS 5.11 Last change: 27 Jan 2002 3
|