Table of Contents | Previous | Next | Index

Netscape Directory SDK 3.0 for C Programmer’s Guide
     Chapter 18 Functions

ldap_get_lderrno()

The ldap_get_lderrno() function gets information about the last error that occurred for an LDAP operation. You can also call this function to get error codes for functions that do not return errors (such as ldap_next_attribute()).

For more information, see "Getting Information About the Error" on page 72.

Syntax

#include <ldap.h>
int ldap_get_lderrno( LDAP *ld, char **m, char **s );

Parameters

This function has the following parameters:

ld

Connection handle, which is a pointer to an LDAP structure containing information about the connection to the LDAP server.

m

In the event of an LDAP_NO_SUCH_OBJECT error return, this parameter contains the portion of the DN that identifies an existing entry. (See "Receiving the Portion of the DN Matching an Entry" on page 73.)

s

The text of the error message.

Returns

The LDAP error code for the last operation. (See "Result Codes" on page 691 for a complete listing of error codes.)

Example

The following section of code attempts to add a new user to the directory. If the entry identified by a DN does not exist, the server sends the client a portion of the DN that find an existing entry. This DN is returned to the client as the variable matched. (See "Receiving the Portion of the DN Matching an Entry" on page 73 for details.)

#include <ldap.h>
LDAP *ld;
char *dn = "uid=bjensen, ou=People, o=Airius.com";
LDAPMod **list_of_attrs;
char *matched;
int rc;
...
if ( ldap_add_s( ld, dn, list_of_attrs ) != LDAP_SUCCESS ) {
   rc = ldap_get_lderrno( ld, &matched, NULL );
   return( rc );
}
...
In the example above, if no organizational unit named New Department exists, the matched variable is set to:

o=Airius.com

See Also

ldap_err2string(), ldap_perror(), ldap_result2error(), ldap_set_lderrno().


Table of Contents | Previous | Next | Index

Last Updated: 10/01/98 17:06:23