Esempio n. 1
0
 /**
  * Applies extra attributes to the returned array.
  */
 private function applyExtraAttributes()
 {
     // Convert distinguished name string into an array
     if ($this->hasAttribute('distinguishedname')) {
         $dn = $this->getAttribute('distinguishedname');
         $this->setAttribute('dn', $dn);
         $this->setAttribute('dn_array', $this->connection->explodeDn($dn, true));
     }
     // Convert the object category string into an array
     if ($this->hasAttribute('objectcategory')) {
         $oc = $this->getAttribute('objectcategory');
         $this->setAttribute('oc', $oc);
         $this->setAttribute('oc_array', $this->connection->explodeDn($oc, true));
     }
 }
Esempio n. 2
0
 /**
  * Adds the inserted field, operator and value
  * to the orWheres property array.
  *
  * @param string $field
  * @param string $operator
  * @param null   $value
  *
  * @throws InvalidQueryOperator
  */
 private function addOrWhere($field, $operator, $value = null)
 {
     $this->orWheres[] = ['field' => $field, 'operator' => $this->getOperator($operator), 'value' => $this->connection->escape($value)];
 }
Esempio n. 3
0
 /**
  * Binds to the current connection using the
  * inserted credentials.
  *
  * @param string $username
  * @param string $password
  * @returns bool
  *
  * @throws AdldapException
  */
 private function bindUsingCredentials($username, $password)
 {
     // Allow binding with null credentials
     if (empty($username)) {
         $username = null;
     } else {
         $username .= $this->getAccountSuffix();
     }
     if (empty($password)) {
         $password = null;
     }
     $this->ldapConnection->bind($username, $password);
     if (!$this->ldapConnection->isBound()) {
         $error = $this->ldapConnection->getLastError();
         if ($this->ldapConnection->isUsingSSL() && !$this->ldapConnection->isUsingTLS()) {
             $message = 'Bind to Active Directory failed. Either the LDAPs connection failed or the login credentials are incorrect. AD said: ' . $error;
         } else {
             $message = 'Bind to Active Directory failed. Check the login credentials and/or server details. AD said: ' . $error;
         }
         throw new AdldapException($message);
     }
     return true;
 }