Skip to content

Commit

Permalink
added LDAP setting that will send disabled users to a trash ou
Browse files Browse the repository at this point in the history
  • Loading branch information
MelonSmasher committed Aug 31, 2017
1 parent 028f133 commit 5fa6fd8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/Http/Controllers/Backend/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function getSettings()
$ldap_delete_users = Settings::get('ldap-delete-users', false);
$checked_delete_users = ($ldap_delete_users) ? 'checked' : '';
$ldap_duties_map_to_ou = Settings::get('ldap-duties-map-to-ou', true);
$ldap_use_trash_ou = Settings::get('ldap-use-trash-ou', true);
$checked_duties_map_to_ou = ($ldap_duties_map_to_ou) ? 'checked' : '';
$ldap_home_drive_letter = Settings::get('ldap-home-drive-letter', '');
$ldap_home_drive_path = Settings::get('ldap-home-drive-path-pattern', '');
Expand Down Expand Up @@ -64,6 +65,7 @@ public function getSettings()
'ldap_home_drive_letter' => $ldap_home_drive_letter,
'ldap_home_drive_path' => $ldap_home_drive_path,
'ldap_email_domain' => $ldap_email_domain,
'ldap_use_trash_ou' => $ldap_use_trash_ou
]);
}

Expand Down Expand Up @@ -95,6 +97,7 @@ public function saveSettings(Request $request)
'ldap_home_drive_path' => 'required_with:ldap_enabled',
'ldap_email_domain' => 'required_with:ldap_enabled',
'ldap_base_group_dn' => 'required_with:ldap_enabled',
'ldap_use_trash_ou' => 'nullable|integer|min:0|max:1'
]);

if ($validator->fails()) {
Expand All @@ -113,6 +116,10 @@ public function saveSettings(Request $request)
* If this is set to false, the LDAP bridge service is disabled.
*/
Settings::set('ldap-enabled', array_key_exists('ldap_enabled', $data));
/**
* If this is true, disabled users will be placed in a trash OU
*/
Settings::set('ldap-use-trash-ou', array_key_exists('ldap_use_trash_ou', $data));
/**
* This is an array of ldap hosts
*/
Expand Down
1 change: 1 addition & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ function ldap_config()
'home_drive_letter' => Settings::get('ldap-home-drive-letter', ''),
'home_drive_path_pattern' => Settings::get('ldap-home-drive-path-pattern', ''),
'email_domain' => Settings::get('ldap-email-domain', ''),
'use_trash_ou' => Settings::get('ldap-use-trash-ou', true)
];
}

Expand Down
2 changes: 2 additions & 0 deletions database/seeds/SystemEntitiesSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public function run()
* Example: OU=Groups,DC=DOMAIN,DC=TLD
*/
Settings::set('ldap-base-group-dn', '');

$this->call(TrashOUSetting::class);
Model::reguard();
}
}
17 changes: 17 additions & 0 deletions database/seeds/updates/2017_08_31_trash_ou_setting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use Illuminate\Database\Seeder;
use Krucas\Settings\Facades\Settings;

class TrashOUSetting extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Settings::set('ldap-use-trash-ou', true);
}
}
14 changes: 14 additions & 0 deletions resources/views/backend/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@
</div>
</div>

<div class="form-group">
<label class="col-md-4 control-label">Use trash OU</label>
<div class="col-md-6">
<div class="material-switch pull-left">
<input type="checkbox" id="ldap_use_trash_ou" name="ldap_use_trash_ou"
value="{{$ldap_use_trash_ou}}" {{$ldap_use_trash_ou}}>
<label for="ldap_use_trash_ou" class="label-primary"></label>
</div>
<div class="text-center">
<p>If turned on, disabled accounts will be moved to a trash OU.</p>
</div>
</div>
</div>

<div class="form-group{{ $errors->has('ldap_hosts') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Servers</label>

Expand Down

0 comments on commit 5fa6fd8

Please sign in to comment.