SetFetchMode(ADODB_FETCH_ASSOC); $rs = $ldaplink->Execute($filter); if ($rs) { while ($arr = $rs->FetchRow()) { if (isset($arr[$field])) { // Retrieve field $return[] = $arr[$field]; if ($all === false) { break; } } } } // Disconnect $ldaplink->Close(); return ($all ? $return : array_shift($return)) ; } }