diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index 78330cb6a3..b73f0754eb 100644 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -245,26 +245,26 @@ class LdapSync extends Command // Assign the mapped LDAP attributes for each user to the Snipe-IT user fields for ($i = 0; $i < $results['count']; $i++) { $item = []; - $item['username'] = $results[$i][$ldap_map["username"]][0] ?? ''; - $item['display_name'] = $results[$i][$ldap_map["display_name"]][0] ?? ''; - $item['employee_number'] = $results[$i][$ldap_map["emp_num"]][0] ?? ''; - $item['lastname'] = $results[$i][$ldap_map["last_name"]][0] ?? ''; - $item['firstname'] = $results[$i][$ldap_map["first_name"]][0] ?? ''; - $item['email'] = $results[$i][$ldap_map["email"]][0] ?? ''; - $item['ldap_location_override'] = $results[$i]['ldap_location_override'] ?? ''; - $item['location_id'] = $results[$i]['location_id'] ?? ''; - $item['telephone'] = $results[$i][$ldap_map["phone"]][0] ?? ''; - $item['mobile'] = $results[$i][$ldap_map["mobile"]][0] ?? ''; - $item['jobtitle'] = $results[$i][$ldap_map["jobtitle"]][0] ?? ''; - $item['address'] = $results[$i][$ldap_map["address"]][0] ?? ''; - $item['city'] = $results[$i][$ldap_map["city"]][0] ?? ''; - $item['state'] = $results[$i][$ldap_map["state"]][0] ?? ''; - $item['country'] = $results[$i][$ldap_map["country"]][0] ?? ''; - $item['zip'] = $results[$i][$ldap_map["zip"]][0] ?? ''; - $item['department'] = $results[$i][$ldap_map["dept"]][0] ?? ''; - $item['manager'] = $results[$i][$ldap_map["manager"]][0] ?? ''; - $item['location'] = $results[$i][$ldap_map["location"]][0] ?? ''; - $location = $default_location; //initially, set '$location' to the default_location (which may just be `null`) + $item['username'] = $results[$i][$ldap_map["username"]][0] ?? null; + $item['display_name'] = $results[$i][$ldap_map["display_name"]][0] ?? null; + $item['employee_number'] = $results[$i][$ldap_map["emp_num"]][0] ?? null; + $item['lastname'] = $results[$i][$ldap_map["last_name"]][0] ?? null; + $item['firstname'] = $results[$i][$ldap_map["first_name"]][0] ?? null; + $item['email'] = $results[$i][$ldap_map["email"]][0] ?? null; + $item['ldap_location_override'] = $results[$i]['ldap_location_override'] ?? null; + $item['location_id'] = $results[$i]['location_id'] ?? null; + $item['telephone'] = $results[$i][$ldap_map["phone"]][0] ?? null; + $item['mobile'] = $results[$i][$ldap_map["mobile"]][0] ?? null; + $item['jobtitle'] = $results[$i][$ldap_map["jobtitle"]][0] ?? null; + $item['address'] = $results[$i][$ldap_map["address"]][0] ?? null; + $item['city'] = $results[$i][$ldap_map["city"]][0] ?? null; + $item['state'] = $results[$i][$ldap_map["state"]][0] ?? null; + $item['country'] = $results[$i][$ldap_map["country"]][0] ?? null; + $item['zip'] = $results[$i][$ldap_map["zip"]][0] ?? null; + $item['department'] = $results[$i][$ldap_map["dept"]][0] ?? null; + $item['manager'] = $results[$i][$ldap_map["manager"]][0] ?? null; + $item['location'] = $results[$i][$ldap_map["location"]][0] ?? null; + $location = $default_location; //initially, set '$location' to the default_location (which may just be null) // ONLY if you are using the "ldap_location" option *AND* you have an actual result if ($ldap_map["location"] && $item['location']) { @@ -464,6 +464,7 @@ class LdapSync extends Command $errors = ''; if ($user->save()) { + $item['id'] = $user->id; $item['note'] = $item['createorupdate']; $item['status'] = 'success'; if ($item['createorupdate'] === 'created' && $ldap_default_group) { diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index 23bddfb3b4..e133325215 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -169,6 +169,7 @@ class BulkUsersController extends Controller ->conditionallyAddItem('remote') ->conditionallyAddItem('ldap_import') ->conditionallyAddItem('activated') + ->conditionallyAddItem('display_name') ->conditionallyAddItem('start_date') ->conditionallyAddItem('end_date') ->conditionallyAddItem('city') @@ -214,6 +215,10 @@ class BulkUsersController extends Controller $this->update_array['locale'] = null; } + if ($request->input('null_display_name')=='1') { + $this->update_array['display_name'] = null; + } + if (! $manager_conflict) { $this->conditionallyAddItem('manager_id'); } diff --git a/app/Presenters/UserPresenter.php b/app/Presenters/UserPresenter.php index a4b160771f..d069b15434 100644 --- a/app/Presenters/UserPresenter.php +++ b/app/Presenters/UserPresenter.php @@ -79,9 +79,10 @@ class UserPresenter extends Presenter 'field' => 'display_name', 'searchable' => true, 'sortable' => true, - 'switchable' => false, + 'switchable' => true, 'title' => trans('admin/users/table.display_name'), 'visible' => false, + 'formatter' => 'usersLinkFormatter', ], [ 'field' => 'username', 'searchable' => true, diff --git a/resources/views/users/bulk-edit.blade.php b/resources/views/users/bulk-edit.blade.php index 0533bd5cb3..f41760b271 100644 --- a/resources/views/users/bulk-edit.blade.php +++ b/resources/views/users/bulk-edit.blade.php @@ -214,7 +214,7 @@
@if ((config('app.lock_passwords') || (!Auth::user()->isSuperUser()))) - {{ trans('admin/users/general.group_memberships_helpblock') }}

+

{{ trans('admin/users/general.group_memberships_helpblock') }}

@else
+ {!! $errors->first('display_name', ' :message') !!} +
+
+ +
+
+
diff --git a/resources/views/users/index.blade.php b/resources/views/users/index.blade.php index bfd0e56554..5e42e17df8 100755 --- a/resources/views/users/index.blade.php +++ b/resources/views/users/index.blade.php @@ -20,7 +20,7 @@ @can('create', \App\Models\User::class) @if ($snipeSettings->ldap_enabled == 1) - {{trans('general.ldap_sync')}} + {{trans('general.ldap_sync')}} @endif @endcan @stop diff --git a/resources/views/users/ldap.blade.php b/resources/views/users/ldap.blade.php index d15bf2c3f4..9d8200090f 100644 --- a/resources/views/users/ldap.blade.php +++ b/resources/views/users/ldap.blade.php @@ -16,7 +16,7 @@ @section('content')
-
+
@if ($snipeSettings->ldap_enabled == 0) {{ trans('admin/users/message.ldap_not_configured') }} @else @@ -26,19 +26,18 @@
-

{!! trans('admin/users/general.ldap_sync_intro', ['link' => 'https://snipe-it.readme.io/docs/ldap-sync#/']) !!}

- -
- - @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.ldap_sync_location'), 'help_text' => trans('admin/users/general.ldap_config_text'), 'fieldname' => 'location_id[]', 'multiple' => true]) -
- + +
+ + @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.ldap_sync_location'), 'help_text' => trans('admin/users/general.ldap_config_text'), 'fieldname' => 'location_id[]', 'multiple' => true]) +
+
-
- -
@@ -62,30 +59,52 @@ @if (Session::get('summary'))
-
+

{{ trans('general.sync_results') }}

- +
+ - - - + + + + + + + + + + @foreach (Session::get('summary') as $entry) - + + + @endforeach +
{{ trans('general.username') }}{{ trans('general.employee_number') }}{{ trans('general.first_name') }}{{ trans('general.last_name') }}{{ trans('general.email') }}{{ trans('general.notes') }}{{ trans('general.id') }}{{ trans('general.username') }}{{ trans('admin/users/table.display_name') }}{{ trans('general.employee_number') }}{{ trans('general.first_name') }}{{ trans('general.last_name') }}{{ trans('general.email') }}{{ trans('general.notes') }}
{{ $entry['id'] }} {{ $entry['username'] }}{{ $entry['display_name'] }} {{ $entry['employee_number'] }} {{ $entry['firstname'] }} {{ $entry['lastname'] }} {{ $entry['email'] }} @if ($entry['status']=='success') - {!! $entry['note'] !!} + {!! $entry['note'] !!} @else @endif @@ -93,6 +112,7 @@
@@ -106,7 +126,9 @@ @section('moar_scripts') -