Fix for LDAP syncing with base_dn and location_id and location

This commit is contained in:
Brady Wetherington 2024-01-24 11:54:29 +00:00
parent 2fa5eb4365
commit 3bc1b9038d

View file

@ -88,18 +88,20 @@ class LdapSync extends Command
/** /**
* if a location ID has been specified, use that OU * 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){ foreach($this->option('location_id') as $location_id){
$location_ou = Location::where('id', '=', $location_id)->value('ldap_ou'); $location_ou = Location::where('id', '=', $location_id)->value('ldap_ou');
$search_base = $location_ou; $search_base = $location_ou;
Log::debug('Importing users from specified location OU: \"'.$search_base.'\".'); 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'); $search_base = $this->option('base_dn');
Log::debug('Importing users from specified base DN: \"'.$search_base.'\".'); 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 . ')'); 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) { foreach($this->option('location_id') as $location_id) {
if ($location = Location::where('id', '=', $location_id)->first()) { if ($location = Location::where('id', '=', $location_id)->first()) {
Log::debug('Location ID ' . $location_id . ' passed'); Log::debug('Location ID ' . $location_id . ' passed');