src/Mmi/Ldap/LdapClient.php
public function findUser($filter = '*', $limit = 100, array $searchFields = ['mail', 'cn', 'uid', 'sAMAccountname'], $dn = null)
    {
        //brak możliwości zalogowania
        if (!$this->authenticate($this->_config->user, $this->_config->password)) {
            throw new LdapException('Unable to find users due to "' . $this->_config->user . '" is not authorized');
        }
        try {
            //budowanie filtra
            $searchString = '(|';
            foreach ($searchFields as $field) {
                $searchString .= '(' . $field . '=' . $filter . ')';
            }
            $searchString .= ')';
            //odpowiedź z LDAP'a
            $rawResource = ldap_search($this->_getActiveServer(), $dn ? : 'dc=' . implode(',dc=', explode('.', $this->_config->domain)), $searchString);
        } catch (\Exception $e) {
            //puste
            return new LdapUserCollection;
        }
        //konwersja do obiektów
        return new LdapUserCollection(ldap_get_entries($this->_getActiveServer(), $rawResource), $limit);
    }
public function findUser($filter = '*', $limit = 100, array $searchFields = ['mail', 'cn', 'uid', 'sAMAccountname'], $dn = null)
    {
        //brak możliwości zalogowania
        if (!$this->authenticate($this->_config->user, $this->_config->password)) {
            throw new LdapException('Unable to find users due to "' . $this->_config->user . '" is not authorized');
        }
        try {
            //budowanie filtra
            $searchString = '(|';
            foreach ($searchFields as $field) {
                $searchString .= '(' . $field . '=' . $filter . ')';
            }
            $searchString .= ')';
            //odpowiedź z LDAP'a
            $rawResource = ldap_search($this->_getActiveServer(), $dn ? : 'dc=' . implode(',dc=', explode('.', $this->_config->domain)), $searchString);
        } catch (\Exception $e) {
            //puste
            return new LdapUserCollection;
        }
        //konwersja do obiektów
        return new LdapUserCollection(ldap_get_entries($this->_getActiveServer(), $rawResource), $limit);
    }
public function findUser ( $ filter = '*' , $ limit = 100 , array $ searchFields = [ 'mail' , 'cn' , 'uid' , 'sAMAccountname' ] , $ dn = null ) { //brak możliwości zalogowania if ( ! $ this -> authenticate ( $ this -> _config -> user , $ this -> _config -> password ) ) { throw new LdapException ( 'Unable to find users due to "' . $ this -> _config -> user . '" is not authorized' ) ; } try { //budowanie filtra $ searchString = '(|' ; foreach ( $ searchFields as $ field ) { $ searchString .= '(' . $ field . '=' . $ filter . ')' ; } $ searchString .= ')' ; //odpowiedź z LDAP'a $ rawResource = ldap_search ( $ this -> _getActiveServer ( ) , $ dn ? : 'dc=' . implode ( ',dc=' , explode ( '.' , $ this -> _config -> domain ) ) , $ searchString ) ; } catch ( \ Exception $ e ) { //puste return new LdapUserCollection ; } //konwersja do obiektów return new LdapUserCollection ( ldap_get_entries ( $ this -> _getActiveServer ( ) , $ rawResource ) , $ limit ) ; }
Znajduje po filtrze
@param string $filter
@param integer $limit
@param string $dn opcjonalny dn
@return \Mmi\LdapUserCollection
Znajduje po filtrze