Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function bindUsingKerberos($kerberosCredentials)
 {
     $key = 'KRB5CCNAME=';
     putenv($key . $kerberosCredentials);
     if ($this->connection->bind(null, null, true) === false) {
         $error = $this->connection->getLastError();
         $message = "Bind to Active Directory failed. AD said: {$error}";
         throw new BindException($message);
     }
 }
Beispiel #2
0
 /**
  * Processes LDAP search results and constructs their model instances.
  *
  * @param resource $results
  *
  * @return array
  */
 public function process($results)
 {
     $entries = $this->connection->getEntries($results);
     if ($this->builder->isRaw() === true) {
         return $entries;
     } else {
         $models = [];
         if (is_array($entries) && array_key_exists('count', $entries)) {
             for ($i = 0; $i < $entries['count']; $i++) {
                 $models[] = $this->newLdapEntry($entries[$i]);
             }
         }
         // If the current query isn't paginated,
         // we'll sort the models array here.
         if (!$this->builder->isPaginated()) {
             $models = $this->processSort($models);
         }
         return $models;
     }
 }
Beispiel #3
0
 /**
  * Prepares the connection by setting configured parameters.
  *
  * @return void
  */
 protected function prepareConnection()
 {
     // Set the beginning protocol options on the connection
     // if they're set in the configuration.
     if ($this->configuration->getUseSSL()) {
         $this->connection->useSSL();
     } elseif ($this->configuration->getUseTLS()) {
         $this->connection->useTLS();
     }
     // If we've set SSO to true, we'll make sure we check if
     // SSO is supported, and if so we'll bind it to
     // the current LDAP connection.
     if ($this->configuration->getUseSSO() && $this->connection->isSaslSupported()) {
         $this->connection->useSSO();
     }
 }
Beispiel #4
0
 /**
  * Paginates the current LDAP query.
  *
  * @param int  $perPage
  * @param int  $currentPage
  * @param bool $isCritical
  *
  * @return Paginator|bool
  */
 public function paginate($perPage = 50, $currentPage = 0, $isCritical = true)
 {
     // Set the current query to paginated
     $this->paginated = true;
     // Stores all LDAP entries in a page array
     $pages = [];
     $cookie = '';
     do {
         $this->connection->controlPagedResult($perPage, $isCritical, $cookie);
         $results = $this->connection->search($this->getDn(), $this->getQuery(), $this->getSelects());
         if ($results) {
             $this->connection->controlPagedResultResponse($results, $cookie);
             // We'll collect the results into the pages array.
             $pages[] = $results;
         }
     } while ($cookie !== null && !empty($cookie));
     if (count($pages) > 0) {
         return $this->newProcessor()->processPaginated($pages, $perPage, $currentPage);
     }
     return false;
 }