diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index 975db4f5d7..dd6fea8b66 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -62,6 +62,7 @@ class LdapSync extends Command $ldap_result_phone = Setting::getSettings()->ldap_phone_field; $ldap_result_jobtitle = Setting::getSettings()->ldap_jobtitle; $ldap_result_country = Setting::getSettings()->ldap_country; + $ldap_result_location = Setting::getSettings()->ldap_location; $ldap_result_dept = Setting::getSettings()->ldap_dept; $ldap_result_manager = Setting::getSettings()->ldap_manager; $ldap_default_group = Setting::getSettings()->ldap_default_group; @@ -209,8 +210,11 @@ class LdapSync extends Command $item['country'] = $results[$i][$ldap_result_country][0] ?? ''; $item['department'] = $results[$i][$ldap_result_dept][0] ?? ''; $item['manager'] = $results[$i][$ldap_result_manager][0] ?? ''; + $item['location'] = $results[$i][$ldap_result_location][0] ?? ''; - + $location = Location::firstOrCreate([ + 'name' => $item['location'], + ]); $department = Department::firstOrCreate([ 'name' => $item['department'], ]); @@ -236,6 +240,7 @@ class LdapSync extends Command $user->jobtitle = $item['jobtitle']; $user->country = $item['country']; $user->department_id = $department->id; + $user->location_id = $location->id; if($item['manager'] != null) { // Check Cache first diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index f16a6fc8f0..c65dbc7d27 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -961,6 +961,7 @@ class SettingsController extends Controller $setting->ldap_phone_field = $request->input('ldap_phone'); $setting->ldap_jobtitle = $request->input('ldap_jobtitle'); $setting->ldap_country = $request->input('ldap_country'); + $setting->ldap_location = $request->input('ldap_location'); $setting->ldap_dept = $request->input('ldap_dept'); $setting->ldap_client_tls_cert = $request->input('ldap_client_tls_cert'); $setting->ldap_client_tls_key = $request->input('ldap_client_tls_key'); diff --git a/app/Models/Ldap.php b/app/Models/Ldap.php index a29581bf97..4eb496a2ab 100644 --- a/app/Models/Ldap.php +++ b/app/Models/Ldap.php @@ -213,6 +213,7 @@ class Ldap extends Model $ldap_result_phone = Setting::getSettings()->ldap_phone; $ldap_result_jobtitle = Setting::getSettings()->ldap_jobtitle; $ldap_result_country = Setting::getSettings()->ldap_country; + $ldap_result_location = Setting::getSettings()->ldap_location; $ldap_result_dept = Setting::getSettings()->ldap_dept; $ldap_result_manager = Setting::getSettings()->ldap_manager; // Get LDAP user data @@ -227,6 +228,7 @@ class Ldap extends Model $item['country'] = $ldapattributes[$ldap_result_country][0] ?? ''; $item['department'] = $ldapattributes[$ldap_result_dept][0] ?? ''; $item['manager'] = $ldapattributes[$ldap_result_manager][0] ?? ''; + $item['location'] = $ldapattributes[$ldap_result_location][0] ?? ''; return $item; } diff --git a/app/Models/Setting.php b/app/Models/Setting.php index ecac183356..61be790e00 100755 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -341,7 +341,15 @@ class Setting extends Model 'ad_domain', 'ad_append_domain', 'ldap_client_tls_key', - 'ldap_client_tls_cert' + 'ldap_client_tls_cert', + 'ldap_default_group', + 'ldap_dept', + 'ldap_emp_num', + 'ldap_phone_field', + 'ldap_jobtitle', + 'ldap_manager', + 'ldap_country', + 'ldap_location', ])->first()->getAttributes(); return collect($ldapSettings); diff --git a/database/migrations/2023_04_25_181817_adds_ldap_location_to_settings_table.php b/database/migrations/2023_04_25_181817_adds_ldap_location_to_settings_table.php new file mode 100644 index 0000000000..60c0e31a67 --- /dev/null +++ b/database/migrations/2023_04_25_181817_adds_ldap_location_to_settings_table.php @@ -0,0 +1,32 @@ +string('ldap_location')->after('ldap_country')->nullable()->default(null); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn('ldap_location'); + }); + } +} diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index c76bb02b55..c69c944579 100644 --- a/resources/lang/en/admin/settings/general.php +++ b/resources/lang/en/admin/settings/general.php @@ -86,6 +86,8 @@ return [ 'ldap_settings' => 'LDAP Settings', 'ldap_client_tls_cert_help' => 'Client-Side TLS Certificate and Key for LDAP connections are usually only useful in Google Workspace configurations with "Secure LDAP." Both are required.', 'ldap_client_tls_key' => 'LDAP Client-Side TLS key', + 'ldap_location' => 'LDAP Location', +'ldap_location_help' => 'The Ldap Location field should be used if an OU is not being used in the Base Bind DN. Leave this blank if an OU search is being used.', 'ldap_login_test_help' => 'Enter a valid LDAP username and password from the base DN you specified above to test whether your LDAP login is configured correctly. YOU MUST SAVE YOUR UPDATED LDAP SETTINGS FIRST.', 'ldap_login_sync_help' => 'This only tests that LDAP can sync correctly. If your LDAP Authentication query is not correct, users may still not be able to login. YOU MUST SAVE YOUR UPDATED LDAP SETTINGS FIRST.', 'ldap_manager' => 'LDAP Manager', diff --git a/resources/views/settings/ldap.blade.php b/resources/views/settings/ldap.blade.php index 19153a0bb2..078b09cad5 100644 --- a/resources/views/settings/ldap.blade.php +++ b/resources/views/settings/ldap.blade.php @@ -499,6 +499,20 @@ @endif + +
{!! trans('admin/settings/general.ldap_location_help') !!}
+ {!! $errors->first('ldap_location', ' ') !!} + @if (config('app.lock_passwords')===true) +{{ trans('general.feature_disabled') }}
+ @endif +