Error handling

Error handling – How handling errors works in Net_LDAP2

Error handling

Nearly all of Net_LDAPs methods return a Net_LDAP2_Error object if something went wrong. You always should check for errors after you performed an action to be sure that your application doesn't do things you don't want it to do.

Handling errors is an easy task, you just have to test the return value as shown below. If an error occured, you can halt the script for example. In other cases, you may just log the error, but what exactly happens depends on your specific situation, of course.

You can use the getMessage() method of the error object to retrieve the error message explaining the problem and getCode() to get the error code which is usually the LDAP-Error code (see Table below) and may be used for automated reaction on errors.

Dealing with errors

<?php
// Perform an arbitrary action:
$result $ldap->search($searchbase$filter$options);

// Check, if an error occured and do something.
// Here we use die() to show the message of the error.
if (Net_LDAP2::isError($result)) {
    die(
$result->getMessage());
}
?>
Error codes Net_LDAP2
Error code Description
0x00LDAP_SUCCESS
0x01LDAP_OPERATIONS_ERROR
0x02LDAP_PROTOCOL_ERROR
0x03LDAP_TIMELIMIT_EXCEEDED
0x04LDAP_SIZELIMIT_EXCEEDED
0x05LDAP_COMPARE_FALSE
0x06LDAP_COMPARE_TRUE
0x07LDAP_AUTH_METHOD_NOT_SUPPORTED
0x08LDAP_STRONG_AUTH_REQUIRED
0x09LDAP_PARTIAL_RESULTS
0x0aLDAP_REFERRAL
0x0bLDAP_ADMINLIMIT_EXCEEDED
0x0cLDAP_UNAVAILABLE_CRITICAL_EXTENSION
0x0dLDAP_CONFIDENTIALITY_REQUIRED
0x0eLDAP_SASL_BIND_INPROGRESS
0x10LDAP_NO_SUCH_ATTRIBUTE
0x11LDAP_UNDEFINED_TYPE
0x12LDAP_INAPPROPRIATE_MATCHING
0x13LDAP_CONSTRAINT_VIOLATION
0x14LDAP_TYPE_OR_VALUE_EXISTS
0x15LDAP_INVALID_SYNTAX
0x20LDAP_NO_SUCH_OBJECT
0x21LDAP_ALIAS_PROBLEM
0x22LDAP_INVALID_DN_SYNTAX
0x23LDAP_IS_LEAF
0x24LDAP_ALIAS_DEREF_PROBLEM
0x30LDAP_INAPPROPRIATE_AUTH
0x31LDAP_INVALID_CREDENTIALS
0x32LDAP_INSUFFICIENT_ACCESS
0x33LDAP_BUSY
0x34LDAP_UNAVAILABLE
0x35LDAP_UNWILLING_TO_PERFORM
0x36LDAP_LOOP_DETECT
0x3CLDAP_SORT_CONTROL_MISSING
0x3DLDAP_INDEX_RANGE_ERROR
0x40LDAP_NAMING_VIOLATION
0x41LDAP_OBJECT_CLASS_VIOLATION
0x42LDAP_NOT_ALLOWED_ON_NONLEAF
0x43LDAP_NOT_ALLOWED_ON_RDN
0x44LDAP_ALREADY_EXISTS
0x45LDAP_NO_OBJECT_CLASS_MODS
0x46LDAP_RESULTS_TOO_LARGE
0x47LDAP_AFFECTS_MULTIPLE_DSAS
0x50LDAP_OTHER
0x51LDAP_SERVER_DOWN
0x52LDAP_LOCAL_ERROR
0x53LDAP_ENCODING_ERROR
0x54LDAP_DECODING_ERROR
0x55LDAP_TIMEOUT
0x56LDAP_AUTH_UNKNOWN
0x57LDAP_FILTER_ERROR
0x58LDAP_USER_CANCELLED
0x59LDAP_PARAM_ERROR
0x5aLDAP_NO_MEMORY
0x5bLDAP_CONNECT_ERROR
0x5cLDAP_NOT_SUPPORTED
0x5dLDAP_CONTROL_NOT_FOUND
0x5eLDAP_NO_RESULTS_RETURNED
0x5fLDAP_MORE_RESULTS_TO_RETURN
0x60LDAP_CLIENT_LOOP
0x61LDAP_REFERRAL_LIMIT_EXCEEDED
1000Unknown Net_LDAP2 Error
What Net_LDAP2 is and general information (Previous) How to configure Net_LDAP2 and connect to an LDAP server (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.