mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Merge pull request #8313 from snipe/improve_ldap_search_error_reporting
Improve ldap search error reporting
This commit is contained in:
commit
9ca20e4964
|
@ -124,7 +124,16 @@ class LdapSync extends Command
|
||||||
|
|
||||||
// Grab subsets based on location-specific DNs, and overwrite location for these users.
|
// Grab subsets based on location-specific DNs, and overwrite location for these users.
|
||||||
foreach ($ldap_ou_locations as $ldap_loc) {
|
foreach ($ldap_ou_locations as $ldap_loc) {
|
||||||
|
try {
|
||||||
$location_users = Ldap::findLdapUsers($ldap_loc["ldap_ou"]);
|
$location_users = Ldap::findLdapUsers($ldap_loc["ldap_ou"]);
|
||||||
|
} catch (\Exception $e) { // FIXME: this is stolen from line 77 or so above
|
||||||
|
if ($this->option('json_summary')) {
|
||||||
|
$json_summary = [ "error" => true, "error_message" => trans('admin/users/message.error.ldap_could_not_search')." Location: ".$ldap_loc['name']." (ID: ".$ldap_loc['id'].") cannot connect to \"".$ldap_loc["ldap_ou"]."\" - ".$e->getMessage(), "summary" => [] ];
|
||||||
|
$this->info(json_encode($json_summary));
|
||||||
|
}
|
||||||
|
LOG::info($e);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
$usernames = array();
|
$usernames = array();
|
||||||
for ($i = 0; $i < $location_users["count"]; $i++) {
|
for ($i = 0; $i < $location_users["count"]; $i++) {
|
||||||
|
|
||||||
|
@ -264,7 +273,7 @@ class LdapSync extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($this->option('json_summary')) {
|
} else if ($this->option('json_summary')) {
|
||||||
$json_summary = [ "error" => false, "error_message" => "", "summary" => $summary ];
|
$json_summary = [ "error" => false, "error_message" => "", "summary" => $summary ]; // hardcoding the error to false and the error_message to blank seems a bit weird
|
||||||
$this->info(json_encode($json_summary));
|
$this->info(json_encode($json_summary));
|
||||||
} else {
|
} else {
|
||||||
return $summary;
|
return $summary;
|
||||||
|
|
|
@ -265,13 +265,13 @@ class Ldap extends Model
|
||||||
$search_results = ldap_search($ldapconn, $base_dn, '('.$filter.')');
|
$search_results = ldap_search($ldapconn, $base_dn, '('.$filter.')');
|
||||||
|
|
||||||
if (!$search_results) {
|
if (!$search_results) {
|
||||||
return redirect()->route('users.index')->with('error', trans('admin/users/message.error.ldap_could_not_search').ldap_error($ldapconn));
|
return redirect()->route('users.index')->with('error', trans('admin/users/message.error.ldap_could_not_search').ldap_error($ldapconn)); // FIXME this is never called in any routed context - only from the Artisan command. So this redirect will never work.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get results from page
|
// 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.index')->with('error', trans('admin/users/message.error.ldap_could_not_get_entries').ldap_error($ldapconn));
|
return redirect()->route('users.index')->with('error', trans('admin/users/message.error.ldap_could_not_get_entries').ldap_error($ldapconn)); // FIXME this is never called in any routed context - only from the Artisan command. So this redirect will never work.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add results to result set
|
// Add results to result set
|
||||||
|
|
Loading…
Reference in a new issue