diff options
author | Marc Hefter <marchefter@gmail.com> | 2023-04-21 10:35:44 +0200 |
---|---|---|
committer | Marc Hefter <marchefter@gmail.com> | 2023-04-21 10:35:44 +0200 |
commit | e83520617d19833e8b85424c7cb51f5773ec20d0 (patch) | |
tree | 132f00568e4892d6c534a95647ea2c87083e088d | |
parent | c08026a92ab020ac327aa7b8d379fc26cfe447bd (diff) | |
download | nextcloud-server-e83520617d19833e8b85424c7cb51f5773ec20d0.tar.gz nextcloud-server-e83520617d19833e8b85424c7cb51f5773ec20d0.zip |
removed profile data from LDAP will get removed
If attribute mapping is configured and no value present in LDAP, the
according profile field is emptied. Removing an attribute e.g. phone
from LDAP will cause the phone number being removed from profile.
Signed-off-by: Marc Hefter <marchefter@gmail.com>
-rw-r--r-- | apps/user_ldap/lib/User/User.php | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index f6a3bf70792..20a7baa66dd 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -249,9 +249,9 @@ class User { $profileValues = array(); //User Profile Field - Phone number $attr = strtolower($this->connection->ldapAttributePhone); - if (isset($ldapEntry[$attr])) { + if (!empty($attr)) { // attribute configured $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_PHONE] - = $ldapEntry[$attr][0]; + = (isset($ldapEntry[$attr]) ? $ldapEntry[$attr][0] : ""); } //User Profile Field - website $attr = strtolower($this->connection->ldapAttributeWebsite); @@ -265,6 +265,8 @@ class User { $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_WEBSITE] = $ldapEntry[$attr][0]; } + } elseif (!empty($attr)) { // configured, but not defined + $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_WEBSITE] = ""; } //User Profile Field - Address $attr = strtolower($this->connection->ldapAttributeAddress); @@ -277,36 +279,38 @@ class User { $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_ADDRESS] = $ldapEntry[$attr][0]; } + } elseif (!empty($attr)) { // configured, but not defined + $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_ADDRESS] = ""; } //User Profile Field - Twitter $attr = strtolower($this->connection->ldapAttributeTwitter); - if (isset($ldapEntry[$attr])) { + if (!empty($attr)) { $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_TWITTER] - = $ldapEntry[$attr][0]; + = (isset($ldapEntry[$attr]) ? $ldapEntry[$attr][0] : ""); } //User Profile Field - fediverse $attr = strtolower($this->connection->ldapAttributeFediverse); - if (isset($ldapEntry[$attr])) { + if (!empty($attr)) { $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_FEDIVERSE] - = $ldapEntry[$attr][0]; + = (isset($ldapEntry[$attr]) ? $ldapEntry[$attr][0] : ""); } //User Profile Field - organisation $attr = strtolower($this->connection->ldapAttributeOrganisation); - if (isset($ldapEntry[$attr])) { + if (!empty($attr)) { $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_ORGANISATION] - = $ldapEntry[$attr][0]; + = (isset($ldapEntry[$attr]) ? $ldapEntry[$attr][0] : ""); } //User Profile Field - role $attr = strtolower($this->connection->ldapAttributeRole); - if (isset($ldapEntry[$attr])) { + if (!empty($attr)) { $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_ROLE] - = $ldapEntry[$attr][0]; + = (isset($ldapEntry[$attr]) ? $ldapEntry[$attr][0] : ""); } //User Profile Field - headline $attr = strtolower($this->connection->ldapAttributeHeadline); - if (isset($ldapEntry[$attr])) { + if (!empty($attr)) { $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_HEADLINE] - = $ldapEntry[$attr][0]; + = (isset($ldapEntry[$attr]) ? $ldapEntry[$attr][0] : ""); } //User Profile Field - biography $attr = strtolower($this->connection->ldapAttributeBiography); @@ -319,6 +323,8 @@ class User { $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIOGRAPHY] = $ldapEntry[$attr][0]; } + } elseif (!empty($attr)) { // configured, but not defined + $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_BIOGRAPHY] = ""; } // check for changed data and cache just for TTL checking $checksum = hash('sha256', json_encode($profileValues)); |