Converting LDAP Error Numbers to Messages
The ldap_err2str() function translates one of LDAP??™s standard error numbers to its
corresponding string representation. Its prototype follows:
string ldap_err2str(int errno)
For example, error integer 3 represents the time limit exceeded error. Therefore,
executing the following function yields an appropriate message:
echo ldap_err2str (3);
442 CHAPTER 17 ?– PHP AND LDAP
This returns the following:
Time limit exceeded
Keep in mind that these error strings might vary slightly, so if you??™re interested in
offering somewhat more user-friendly messages, always base your conversions on
the error number rather than on an error string.
Retrieving the Most Recent Error Number
The LDAP specification offers a standardized list of error codes that might be generated
during interaction with a directory server. If you want to customize the otherwise
terse messages offered by ldap_error() and ldap_err2str(), or if you would like to
log the codes, say, within a database, you can use ldap_errno() to retrieve this code.
Its prototype follows:
int ldap_errno(resource link_id)
Retrieving the Most Recent Error Message
The ldap_error() function retrieves the last error message generated during the LDAP
connection specified by a link identifier. Its prototype follows:
string ldap_error(resource link_id)
Although the list of all possible error codes is far too long to include in this chapter,
a few are presented here just so you can get an idea of what is available:
LDAP_TIMELIMIT_EXCEEDED: The predefined LDAP execution time limit was exceeded.
Pages:
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521