Skip to content

Commit 6f84729

Browse files
authored
Merge pull request #15911 from Fiala06/patch-1
Fixed duplicate entries preventing LDAP sync from continuing
2 parents d556d1c + bdb0e6c commit 6f84729

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/Console/Commands/LdapSync.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,12 @@ public function handle()
434434
$item['note'] = $item['createorupdate'];
435435
$item['status'] = 'success';
436436
if ($item['createorupdate'] === 'created' && $ldap_default_group) {
437-
$user->groups()->attach($ldap_default_group);
437+
// Check if the relationship already exists
438+
if (!$user->groups()->where('group_id', $ldap_default_group)->exists()) {
439+
$user->groups()->attach($ldap_default_group);
440+
}
438441
}
442+
439443
//updates assets location based on user's location
440444
if ($user->wasChanged('location_id')) {
441445
foreach ($user->assets as $asset) {

0 commit comments

Comments
 (0)