mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Applied updates from PR for LDAP pagination
This commit is contained in:
parent
bd334076ca
commit
aff133b5f1
|
@ -1149,18 +1149,44 @@ class UsersController extends Controller
|
||||||
return Redirect::route('users')->with('error', Lang::get('admin/users/message.error.ldap_could_not_bind').ldap_error($ldapconn));
|
return Redirect::route('users')->with('error', Lang::get('admin/users/message.error.ldap_could_not_bind').ldap_error($ldapconn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up LDAP pagination for very large databases
|
||||||
|
// @author Richard Hofman
|
||||||
|
$page_size = 500;
|
||||||
|
$cookie = '';
|
||||||
|
$result_set = array();
|
||||||
|
$global_count = 0;
|
||||||
|
|
||||||
// Perform the search
|
// Perform the search
|
||||||
$search_results = @ldap_search($ldapconn, $base_dn, '('.$filter.')');
|
do {
|
||||||
|
// Paginate (non-critical, if not supported by server)
|
||||||
|
ldap_control_paged_result($ldapconn, $page_size, false, $cookie);
|
||||||
|
|
||||||
|
$search_results = ldap_search($ldapconn, $base_dn, '('.$filter.')');
|
||||||
|
|
||||||
if (!$search_results) {
|
if (!$search_results) {
|
||||||
return Redirect::route('users')->with('error', Lang::get('admin/users/message.error.ldap_could_not_search').ldap_error($ldapconn));
|
return Redirect::route('users')->with('error', Lang::get('admin/users/message.error.ldap_could_not_search').ldap_error($ldapconn));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get results
|
// Get results from page
|
||||||
$results = @ldap_get_entries($ldapconn, $search_results);
|
$results = ldap_get_entries($ldapconn, $search_results);
|
||||||
if (!$results) {
|
if (!$results) {
|
||||||
return Redirect::route('users')->with('error', Lang::get('admin/users/message.error.ldap_could_not_get_entries').ldap_error($ldapconn));
|
return Redirect::route('users')->with('error', Lang::get('admin/users/message.error.ldap_could_not_get_entries').ldap_error($ldapconn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add results to result set
|
||||||
|
$global_count += $results['count'];
|
||||||
|
$result_set = array_merge($result_set, $results);
|
||||||
|
|
||||||
|
ldap_control_paged_result_response($ldapconn, $search_results, $cookie);
|
||||||
|
|
||||||
|
} while ($cookie !== null && $cookie != '');
|
||||||
|
|
||||||
|
|
||||||
|
// Clean up after search
|
||||||
|
$result_set['count'] = $global_count;
|
||||||
|
$results = $result_set;
|
||||||
|
ldap_control_paged_result($ldapconn, 0);
|
||||||
|
|
||||||
$summary = array();
|
$summary = array();
|
||||||
|
|
||||||
for ($i = 0; $i < $results["count"]; $i++) {
|
for ($i = 0; $i < $results["count"]; $i++) {
|
||||||
|
|
Loading…
Reference in a new issue