PHP Manual
Prev |  | Next

# ldap_errno

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

## Description

`int ldap_errno`(int link_id);

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 php3.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
      1
      2 <?php
      3 // This example contains an error, which we will catch.
      4 $ld = ldap_connect("localhost");
      5 $bind = ldap_bind($ld);
      6 // syntax error in filter expression (errno 87),
      7 // must be "objectclass=*" to work.
      8 $res =  @ldap_search($ld, "o=Myorg, c=DE", "objectclass");
      9 if (!$res) {
     10     printf("LDAP-Errno: %s<br>\n", ldap_errno($ld));
     11     printf("LDAP-Error: %s<br>\n", ldap_error($ld));
     12     die("Argh!<br>\n");
     13 }
     14 $info = ldap_get_entries($ld, $res);
     15 printf("%d matching entries.<br>\n", $info["count"]);
     16 ?>
     17

see also ldap_err2str() and ldap_error().

Prev | Home | Next
ldap_err2str | Up | ldap_error