getDn() 공개 메소드

Returns the user's DN
public getDn ( string $username ) : string
$username string Username
리턴 string
 /**
  * Checks the password for the given user account.
  *
  * Returns true if the given password for the user account specified by
  * is correct, otherwise false.
  * Error messages are added to the array errors.
  *
  * This function is only called when local authentication has failed, so
  * we are about to create user account.
  *
  * @param string $login        Loginname
  * @param string $password     Password
  * @param array  $optionalData Optional data
  *
  * @return boolean
  */
 public function checkPassword($login, $password, array $optionalData = null)
 {
     if ('' === trim($password)) {
         $this->errors[] = PMF_User::ERROR_USER_INCORRECT_PASSWORD;
         return false;
     }
     $bindLogin = $login;
     if ($this->_ldapConfig['ldap_use_domain_prefix']) {
         if (array_key_exists('domain', $optionalData)) {
             $bindLogin = $optionalData['domain'] . '\\' . $login;
         }
     } else {
         $this->ldap = new PMF_Ldap($this->_config);
         $this->ldap->connect($this->_ldapConfig['ldap_server'], $this->_ldapConfig['ldap_port'], $this->_ldapConfig['ldap_base'], $this->_ldapConfig['ldap_user'], $this->_ldapConfig['ldap_password']);
         if ($this->ldap->error) {
             $this->errors[] = $this->ldap->error;
         }
         $bindLogin = $this->ldap->getDn($login);
     }
     // Check user in LDAP
     $this->ldap = new PMF_Ldap($this->_config);
     $this->ldap->connect($this->_ldapConfig['ldap_server'], $this->_ldapConfig['ldap_port'], $this->_ldapConfig['ldap_base'], $bindLogin, $password);
     if (!$this->ldap->bind($bindLogin, $password)) {
         $this->errors[] = $this->ldap->error;
         return false;
     } else {
         $this->add($login, $password);
         return true;
     }
 }
예제 #2
0
 /**
  * Checks the password for the given user account.
  *
  * Returns true if the given password for the user account specified by
  * is correct, otherwise false.
  * Error messages are added to the array errors.
  *
  * This function is only called when local authentication has failed, so
  * we are about to create user account.
  *
  * @param string $login        Loginname
  * @param string $pass         Password
  * @param array  $optionalData Optional data
  *
  * @return boolean
  */
 public function checkPassword($login, $pass, array $optionalData = null)
 {
     if ('' === trim($pass)) {
         $this->errors[] = PMF_User::ERROR_USER_INCORRECT_PASSWORD;
         return false;
     }
     // Get active LDAP server for current user
     if ($this->multipleServers) {
         // Try all LDAP servers
         foreach ($this->ldapServer as $key => $value) {
             $this->ldap->connect($this->ldapServer[$key]['ldap_server'], $this->ldapServer[$key]['ldap_port'], $this->ldapServer[$key]['ldap_base'], $this->ldapServer[$key]['ldap_user'], $this->ldapServer[$key]['ldap_password']);
             if ($this->ldap->error) {
                 $this->errors[] = $this->ldap->error;
             }
             if (false !== $this->ldap->getDn($login)) {
                 $this->activeServer = $key;
                 break;
             }
         }
     }
     $bindLogin = $login;
     if ($this->_ldapConfig['ldap_use_domain_prefix']) {
         if (array_key_exists('domain', $optionalData)) {
             $bindLogin = $optionalData['domain'] . '\\' . $login;
         }
     } else {
         $this->ldap->connect($this->ldapServer[$this->activeServer]['ldap_server'], $this->ldapServer[$this->activeServer]['ldap_port'], $this->ldapServer[$this->activeServer]['ldap_base'], $this->ldapServer[$this->activeServer]['ldap_user'], $this->ldapServer[$this->activeServer]['ldap_password']);
         if ($this->ldap->error) {
             $this->errors[] = $this->ldap->error;
         }
         $bindLogin = $this->ldap->getDn($login);
     }
     // Check user in LDAP
     $this->ldap = new PMF_Ldap($this->_config);
     $this->ldap->connect($this->ldapServer[$this->activeServer]['ldap_server'], $this->ldapServer[$this->activeServer]['ldap_port'], $this->ldapServer[$this->activeServer]['ldap_base'], $bindLogin, $pass);
     if ($this->ldap->error) {
         $this->errors[] = $this->ldap->error;
         return false;
     } else {
         $this->add($login, $pass);
         return true;
     }
 }
예제 #3
0
 /**
  * Checks the password for the given user account.
  *
  * Returns true if the given password for the user account specified by
  * is correct, otherwise false.
  * Error messages are added to the array errors.
  *
  * This function is only called when local authentication has failed, so
  * we are about to create user account.
  *
  * @param string $login        Loginname
  * @param string $pass         Password
  * @param array  $optionslData Optional data
  * 
  * @return boolean
  */
 public function checkPassword($login, $pass, array $optionalData = null)
 {
     global $PMF_LDAP;
     $bindLogin = $login;
     if ($PMF_LDAP['ldap_use_domain_prefix']) {
         if (array_key_exists('domain', $optionalData)) {
             $bindLogin = $optionalData['domain'] . "\\" . $login;
         }
     } else {
         $this->ldap = new PMF_Ldap($PMF_LDAP['ldap_server'], $PMF_LDAP['ldap_port'], $PMF_LDAP['ldap_base'], $PMF_LDAP['ldap_user'], $PMF_LDAP['ldap_password']);
         if ($this->ldap->error) {
             $this->errors[] = $this->ldap->error;
         }
         $bindLogin = $this->ldap->getDn($login);
     }
     $this->ldap = new PMF_Ldap($PMF_LDAP['ldap_server'], $PMF_LDAP['ldap_port'], $PMF_LDAP['ldap_base'], $bindLogin, $pass);
     if ($this->ldap->error) {
         $this->errors[] = $this->ldap->error;
         return false;
     } else {
         $this->add($login, $pass);
         return true;
     }
 }