function all_users($include_desc = false, $search = "*", $sorted = true){
        if (!$this->_bind){
            return (false);
        }
        
        //perform the search and grab all their details
        $filter = "(&(objectClass=user)(samaccounttype=". ADLDAP_NORMAL_ACCOUNT .")(objectCategory=person)(cn=".$search."))";
        $fields=array($this->_cn_identifier,"displayname");
        $sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
        $entries = $this->ldap_get_entries_raw($sr);

        $users_array = array();
        for ($i=0; $i<$entries["count"]; $i++){
            if ($include_desc && strlen($entries[$i]["displayname"][0])>0){
                $users_array[ $entries[$i][$this->_cn_identifier][0] ] = $entries[$i]["displayname"][0];
            } elseif ($include_desc){
                $users_array[ $entries[$i][$this->_cn_identifier][0] ] = $entries[$i][$this->_cn_identifier][0];
            } else {
                array_push($users_array, $entries[$i][$this->_cn_identifier][0]);
            }
        }
        if ($sorted){ asort($users_array); }
        return ($users_array);
    }
function all_users($include_desc = false, $search = "*", $sorted = true){
        if (!$this->_bind){
            return (false);
        }
        
        //perform the search and grab all their details
        $filter = "(&(objectClass=user)(samaccounttype=". ADLDAP_NORMAL_ACCOUNT .")(objectCategory=person)(cn=".$search."))";
        $fields=array($this->_cn_identifier,"displayname");
        $sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields);
        $entries = $this->ldap_get_entries_raw($sr);

        $users_array = array();
        for ($i=0; $i<$entries["count"]; $i++){
            if ($include_desc && strlen($entries[$i]["displayname"][0])>0){
                $users_array[ $entries[$i][$this->_cn_identifier][0] ] = $entries[$i]["displayname"][0];
            } elseif ($include_desc){
                $users_array[ $entries[$i][$this->_cn_identifier][0] ] = $entries[$i][$this->_cn_identifier][0];
            } else {
                array_push($users_array, $entries[$i][$this->_cn_identifier][0]);
            }
        }
        if ($sorted){ asort($users_array); }
        return ($users_array);
    }
function all_users ( $ include_desc = false , $ search = "*" , $ sorted = true ) { if ( ! $ this -> _bind ) { return ( false ) ; } //perform the search and grab all their details $ filter = "(&(objectClass=user)(samaccounttype=" . ADLDAP_NORMAL_ACCOUNT . ")(objectCategory=person)(cn=" . $ search . "))" ; $ fields = array ( $ this -> _cn_identifier , "displayname" ) ; $ sr = ldap_search ( $ this -> _conn , $ this -> _base_dn , $ filter , $ fields ) ; $ entries = $ this -> ldap_get_entries_raw ( $ sr ) ; $ users_array = array ( ) ; for ( $ i = 0 ; $ i < $ entries [ "count" ] ; $ i ++ ) { if ( $ include_desc && strlen ( $ entries [ $ i ] [ "displayname" ] [ 0 ] ) > 0 ) { $ users_array [ $ entries [ $ i ] [ $ this -> _cn_identifier ] [ 0 ] ] = $ entries [ $ i ] [ "displayname" ] [ 0 ] ; } elseif ( $ include_desc ) { $ users_array [ $ entries [ $ i ] [ $ this -> _cn_identifier ] [ 0 ] ] = $ entries [ $ i ] [ $ this -> _cn_identifier ] [ 0 ] ; } else { array_push ( $ users_array , $ entries [ $ i ] [ $ this -> _cn_identifier ] [ 0 ] ) ; } } if ( $ sorted ) { asort ( $ users_array ) ; } return ( $ users_array ) ; }
Returns all AD users
Returns all AD users