Net_LDAP
[ class tree: Net_LDAP ] [ index: Net_LDAP ] [ all elements ]

Source for file connecting.php

Documentation is available at connecting.php

  1. <?php
  2. /**
  3. * This file shows you how to connect to a ldap server  using Net_LDAP.
  4. *
  5. * It also establishes connections for the other examples;
  6. * they include this file to get a ldap link.
  7. */
  8.  
  9. // Class includes; this assumes Net_LDAP installed in PHPs include path
  10. // or under subfolder "Net" in the local directory.
  11. require_once 'Net/LDAP.php';
  12.  
  13. // Configuration
  14. // host can be a single server (string) or multiple ones - if we define more
  15. // servers here (array), we can implement a basic fail over scenario.
  16. // If no credentials (binddn and bindpw) are given, Net_LDAP establishes
  17. // an anonymous bind.
  18. // See the documentation for more information on the configuration items!
  19. $ldap_config = array(
  20. // 'host'    => 'ldap.example.org',
  21.     'host'    => array('ldap1.example.org''ldap2.example.org'),
  22. // 'binddn'  => 'cn=admin,o=example,dc=org',
  23. // 'bindpw'  => 'your-secret-password',
  24.     'tls'     => false,
  25.     'base'    => 'o=example,dc=org',
  26.     'port'    => 389,
  27.     'version' => 3,
  28.     'filter'  => '(cn=*)',
  29.     'scope'   => 'sub'
  30. );
  31.  
  32. // Connect to configured ldap server
  33. $ldap Net_LDAP::connect($ldap_config);
  34.  
  35. // It is important to check for errors.
  36. // Nearly every method of Net_LDAP returns a Net_LDAP_Error object
  37. // if something went wrong. Through this object, you can retrieve detailed
  38. // information on what exactly happened.
  39. //
  40. // Here we drop a die with the error message, so the other example
  41. // files will not be calles unless we have a valid link.
  42. if (Net_LDAP::isError($ldap)) {
  43.     die('BIND FAILED: '.$ldap->getMessage());
  44. }

Documentation generated on Mon, 11 Mar 2019 15:32:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.