mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Merge pull request #14155 from uberbrady/ldap_location_fixes
Fix for LDAP syncing with base_dn and location_id and location [FD-39651]
This commit is contained in:
commit
1b7885677a
|
@ -88,18 +88,20 @@ class LdapSync extends Command
|
|||
/**
|
||||
* if a location ID has been specified, use that OU
|
||||
*/
|
||||
if ( $this->option('location_id') != '') {
|
||||
if ( $this->option('location_id') ) {
|
||||
|
||||
foreach($this->option('location_id') as $location_id){
|
||||
$location_ou = Location::where('id', '=', $location_id)->value('ldap_ou');
|
||||
$search_base = $location_ou;
|
||||
Log::debug('Importing users from specified location OU: \"'.$search_base.'\".');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Otherwise if a manual base DN has been specified, use that
|
||||
* if a manual base DN has been specified, use that. Allow the Base DN to override
|
||||
* even if there's a location-based DN - if you picked it, you must have picked it for a reason.
|
||||
*/
|
||||
} elseif ($this->option('base_dn') != '') {
|
||||
if ($this->option('base_dn') != '') {
|
||||
$search_base = $this->option('base_dn');
|
||||
Log::debug('Importing users from specified base DN: \"'.$search_base.'\".');
|
||||
}
|
||||
|
@ -125,14 +127,14 @@ class LdapSync extends Command
|
|||
|
||||
/* Determine which location to assign users to by default. */
|
||||
$location = null; // TODO - this would be better called "$default_location", which is more explicit about its purpose
|
||||
if ($this->option('location') != '') {
|
||||
if ($location = Location::where('name', '=', $this->option('location'))->first()) {
|
||||
Log::debug('Location name ' . $this->option('location') . ' passed');
|
||||
Log::debug('Importing to ' . $location->name . ' (' . $location->id . ')');
|
||||
}
|
||||
if ($this->option('location') != '') {
|
||||
if ($location = Location::where('name', '=', $this->option('location'))->first()) {
|
||||
Log::debug('Location name ' . $this->option('location') . ' passed');
|
||||
Log::debug('Importing to ' . $location->name . ' (' . $location->id . ')');
|
||||
}
|
||||
|
||||
} elseif ($this->option('location_id') != '') {
|
||||
foreach($this->option('location_id') as $location_id) {
|
||||
} elseif ($this->option('location_id')) {
|
||||
foreach($this->option('location_id') as $location_id) {
|
||||
if ($location = Location::where('id', '=', $location_id)->first()) {
|
||||
Log::debug('Location ID ' . $location_id . ' passed');
|
||||
Log::debug('Importing to ' . $location->name . ' (' . $location->id . ')');
|
||||
|
|
Loading…
Reference in a new issue