Example #1
0
 /**
  * Establish LDAP connection
  *
  * @static
  * @access public
  * @param  string $username
  * @param  string $password
  * @return Client
  */
 public static function connect($username = null, $password = null)
 {
     $client = new self();
     $client->open($client->getLdapServer());
     $username = $username ?: $client->getLdapUsername();
     $password = $password ?: $client->getLdapPassword();
     if (empty($username) && empty($password)) {
         $client->useAnonymousAuthentication();
     } else {
         $client->authenticate($username, $password);
     }
     return $client;
 }