Developer Forums | About Us | Site Map


Web Host
site hosted by netplex

Online Manuals


(PHP 3>= 3.0.12, PHP 4 )

ldap_errno --  Return the LDAP error number of the last LDAP command


int ldap_errno ( resource link_identifier)

Return the LDAP error number of the last LDAP command for this link.

This function returns the standardized error number returned by the last LDAP command for the given link_identifier. This number can be converted into a textual error message using ldap_err2str().

Unless you lower your warning level in your php.ini sufficiently or prefix your LDAP commands with @ (at) characters to suppress warning output, the errors generated will also show up in your HTML output.

Example 1. Generating and catching an error

// This example contains an error, which we will catch.
$ld = ldap_connect("localhost");
$bind = ldap_bind($ld);
// syntax error in filter expression (errno 87),
// must be "objectclass=*" to work.
$res =  @ldap_search($ld, "o=Myorg, c=DE", "objectclass");
if (!$res) {
    printf("LDAP-Errno: %s<br>\n", ldap_errno($ld));
    printf("LDAP-Error: %s<br>\n", ldap_error($ld));
$info = ldap_get_entries($ld, $res);
printf("%d matching entries.<br>\n", $info["count"]);

See also ldap_err2str() and ldap_error().

Copyright 2004-2019 All rights reserved. Site hosted by NETPLEX