From 9e19e04d8ebcfe142a7e964de87644b3dde34ddc Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Thu, 14 Jan 2021 12:28:12 -0100 Subject: [PATCH] mapping in config --- lib/UserBackend.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/UserBackend.php b/lib/UserBackend.php index adf9edcbd..6e5b5cad1 100644 --- a/lib/UserBackend.php +++ b/lib/UserBackend.php @@ -661,8 +661,17 @@ public function updateAttributes($uid, if ($newGroups !== null) { $prefix = ''; - if ($this->config->getAppValue('user_saml', 'unique_groups_per_idp', '0') === '1') { - list(, $idp) = explode('@', $uid); + $mapping = $this->config->getSystemValue('user_saml.unique_groups_per_idp', ''); + if ($mapping === '') { + $mapping = $this->config->getAppValue('user_saml', 'unique_groups_per_idp', ''); + } + + if ($mapping !== '' && + array_key_exists($mapping, $attributes) && + is_array($attributes[$mapping]) && + sizeof($attributes[$mapping]) === 1) { + $realUid = $attributes[$mapping][0]; + list(, $idp) = explode('@', $realUid); $prefix = substr(md5($idp), 0, 7); $newGroups = array_map( function($g) use ($prefix) {