PMCORE-3817 Authentication Sources does not work when User extended attributes is used

This commit is contained in:
Roly Gutierrez
2022-04-28 14:00:05 -04:00
parent 0f8e7b826d
commit 7eeac2f0dd
2 changed files with 18 additions and 4 deletions

View File

@@ -2994,6 +2994,7 @@ class LdapAdvanced
$this->arrayUserUpdateChecked[$username] = 1; $this->arrayUserUpdateChecked[$username] = 1;
$arrayUserDataUpdate = []; $arrayUserDataUpdate = [];
$extendedData = [];
foreach ($arrayAttributesToSync as $key => $value) { foreach ($arrayAttributesToSync as $key => $value) {
$fieldName = $key; $fieldName = $key;
@@ -3015,12 +3016,24 @@ class LdapAdvanced
break; break;
} }
if ($ldapAttributeValue != $arrayUser[$username][$fieldName]) { if (isset($arrayUser[$username][$fieldName])) {
$arrayUserDataUpdate[$fieldName] = $ldapAttributeValue; if ($ldapAttributeValue != $arrayUser[$username][$fieldName]) {
$arrayUserDataUpdate[$fieldName] = $ldapAttributeValue;
}
} else {
$extendedData[$fieldName] = $ldapAttributeValue;
} }
} }
} }
//update the extended data
if (!empty($extendedData)) {
$json = $arrayUser[$username]['USR_EXTENDED_ATTRIBUTES_DATA'];
$oldExtendedData = empty($json) ? [] : json_decode($json, true);
$extendedData = array_merge($oldExtendedData, $extendedData);
$arrayUserDataUpdate['USR_EXTENDED_ATTRIBUTES_DATA'] = json_encode($extendedData);
}
if (!empty($arrayUserDataUpdate)) { if (!empty($arrayUserDataUpdate)) {
$arrayUserDataUpdate['USR_UID'] = $arrayUser[$username]['USR_UID']; $arrayUserDataUpdate['USR_UID'] = $arrayUser[$username]['USR_UID'];

View File

@@ -109,14 +109,15 @@
deleteAttributeProcess() { deleteAttributeProcess() {
this.rows.splice(this.selectedRowIndex - 1, 1); this.rows.splice(this.selectedRowIndex - 1, 1);
}, },
saveRow(obj) { saveRow(object) {
let obj = Object.assign({}, object);//important to clone the object
if (obj.index === null) { if (obj.index === null) {
delete obj.index; delete obj.index;
this.rows.push(obj); this.rows.push(obj);
} else { } else {
let i = obj.index; let i = obj.index;
delete obj.index; delete obj.index;
this.rows[i - 1] = obj; Object.assign(this.rows[i - 1], obj);
} }
}, },
connectionSettings() { connectionSettings() {