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:
snipe 2024-01-24 13:21:46 +00:00 committed by GitHub
commit 1b7885677a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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.'\".');
}
@ -131,7 +133,7 @@ class LdapSync extends Command
Log::debug('Importing to ' . $location->name . ' (' . $location->id . ')');
}
} elseif ($this->option('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');