Its prototype
follows:
string ldap_dn2ufn(string dn)
This is best illustrated with an example:
// Define the dn
$dn = "OU=People,OU=staff,DC=ad,DC=example,DC=com";
// Convert the DN to a user-friendly format
echo ldap_dn2ufn($dn);
?>
This returns the following:
People, staff, ad.example.com
Loading the DN into an Array
The ldap_explode_dn() function operates much like ldap_dn2ufn(), except that each
component of the DN is returned in an array rather than in a string, with the first
array element containing the array size. Its prototype follows:
array ldap_explode_dn(string dn, int only_values)
If the only_values parameter is set to 0, both the attributes and corresponding values
are included in the array elements; if it is set to 1, just the values are returned. Consider
this example:
CHAPTER 17 ?– PHP A ND LDAP 441
$dn = "OU=People,OU=staff,DC=ad,DC=example,DC=com";
$dnComponents = ldap_explode_dn($dn, 0);
foreach($dnComponents as $component)
printf("%s
", $component);
?>
This returns the following:
5
OU=People
OU=staff
DC=ad
DC=example
DC=com
Error Handling
Although we??™d all like to think of our programming logic and code as foolproof, it
rarely turns out that way. That said, you should use the functions introduced in this
section because they not only aid you in determining causes of error, but also provide
your end users with the pertinent information they need if an error occurs that is due
not to programming faults but to inappropriate or incorrect user actions.
Pages:
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520