updates for active directory now with docs
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Modules\ActiveDirectory\Services;
|
||||
|
||||
use App\Models\User;
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -17,9 +18,11 @@ class SyncDirectoryUsers
|
||||
* changes: list<array{action: string, user_id: ?int, ad_guid: ?string, disabled: bool, changed_fields: list<string>, reason: ?string}>
|
||||
* }
|
||||
*/
|
||||
public function run(bool $dryRun, bool $deactivateMissing, ?string $reviewedMissing = null, bool $matchEmail = false, bool $createMissing = false): array
|
||||
public function run(bool $dryRun, bool $deactivateMissing, ?string $reviewedMissing = null, bool $matchEmail = false, bool $createMissing = false, ?Closure $inspectDirectory = null, bool $includeProperties = false): array
|
||||
{
|
||||
$entries = $this->snapshot();
|
||||
$directoryUsers = $includeProperties ? $this->directory->users(true) : $this->directory->users();
|
||||
$inspectDirectory?->__invoke($directoryUsers);
|
||||
$entries = $this->snapshot($directoryUsers);
|
||||
$source = $this->source();
|
||||
|
||||
return DB::transaction(function () use ($entries, $source, $dryRun, $deactivateMissing, $reviewedMissing, $matchEmail, $createMissing): array {
|
||||
@@ -161,11 +164,11 @@ class SyncDirectoryUsers
|
||||
}
|
||||
|
||||
/** @return array<string, array{email: string, name: string, enabled: bool}> */
|
||||
private function snapshot(): array
|
||||
private function snapshot(array $directoryUsers): array
|
||||
{
|
||||
$entries = [];
|
||||
$emails = [];
|
||||
foreach ($this->directory->users() as $entry) {
|
||||
foreach ($directoryUsers as $entry) {
|
||||
$guid = strtolower((string) $entry['guid']);
|
||||
$email = strtolower(trim($entry['email']));
|
||||
$name = trim($entry['name']);
|
||||
|
||||
Reference in New Issue
Block a user