2.3 LDAP Result Code Structure

An LDAP result code has the following format:

LDAPResult   ::= SEQUENCE {
   resultCode      ENUMERATED,
   matchedDN       LDAPDN,
   errorMessage    LDAPString,
   referral        [3] Referral OPTIONAL
} 

These fields contain the following information.

resultCode

Set to the return code by the LDAP server or the LDAP libraries.

matchedDN

Set to the lowest entry (object or entry) in the directory that was matched when the resultCode field is set to LDAP_NO_SUCH_OBJECT, LDAP_ALIAS_PROBLEM, LDAP_INVALID_DN_SYNTAX, or LDAP_ALIAS_DEREF_PROBLEM. If the resultCode field is set to other result codes, this field is set to a zero-length string.

For example, if the resultCode field is set to LDAP_NO_SUCH_OBJECT, and if the name "CN=Chris, OU=LDAP, O=Novell" is passed in, and if the LDAP server could find the Novell and LDAP entries but not Chris, then this field is set to "OU=LDAP, O=Novell".

errorMessage

Set to a human-readable string that explains the error code.

referral

Optional field that can be set to the URLs of servers that may hold the target entry.

LDAP result codes are returned with each message from the server in a BER-encoded form to the caller of the LDAP function. To retrieve the return code information from a result, use the ldap_parse_result function.