Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[user_ldap] Update profile from LDAP fields #36565

Merged
merged 23 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
404d26a
feature addition: [user_ldap] update user profile from LDAP; WIP work…
march42 May 7, 2022
7fa3c67
feature addition: [user_ldap] update user profile from LDAP; WIP; fix…
march42 May 12, 2022
2315c17
feature addition: [user_ldap] update user profile from LDAP
march42 May 17, 2022
eee0275
added user profile scope setting
march42 May 17, 2022
c7623c7
bugfix: changed forgotten userName, to getUsername
march42 May 20, 2022
b72fbd5
fixed error: Array to string conversion at user_ldap/lib/User/User.ph…
march42 May 21, 2022
240c57b
cleanup: removed unnecessary imports of IAccountManager, AccountManag…
march42 May 21, 2022
26aa1c3
CleanUp: remove unneeded UNSET, to unclutter code
Feb 14, 2023
44065c0
Fix: Parameter $scope has no provided type
march42 Feb 14, 2023
2f76b7a
CleanUp: tidy checking for empty profileScope
Feb 17, 2023
6512738
CleanUp: correct version to 27 and return value specification
march42 Feb 17, 2023
3020290
CleanUp: removed redundant condition if block
Feb 17, 2023
5c4a05c
CleanUp: removed redundant storing profile attributes in user settings
Feb 17, 2023
f812b87
handling updateProfile with array of values
march42 Feb 26, 2023
c640858
fixing Psalm messages
march42 Feb 27, 2023
dd2bd6a
refined code, to be independend from OCP\IUser
march42 Mar 5, 2023
0c6d440
undoing the additions to OC\IUser
march42 Mar 7, 2023
5ea46d8
nice up the code handling AccountManager
march42 Mar 10, 2023
1e7bc93
handling, formatting of postalAddress attribute syntax
march42 Mar 21, 2023
72d0a3f
added simple data conversion for LDAP attributes
march42 Mar 26, 2023
ebb0c53
trying to make github-code-scanning bot happy
march42 Mar 31, 2023
eec5e70
error handling in update profile from LDAP
march42 Apr 11, 2023
6491459
optimized handling of user profile data change
march42 Apr 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions apps/user_ldap/js/wizard/wizardTabAdvanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,44 @@ OCA = OCA || {};
$element: $('#ldap_ext_storage_home_attribute'),
setMethod: 'setExternalStorageHomeAttribute'
},

//User Profile Attributes
ldap_attr_phone: {
$element: $('#ldap_attr_phone'),
setMethod: 'setPhoneAttribute'
},
ldap_attr_website: {
$element: $('#ldap_attr_website'),
setMethod: 'setWebsiteAttribute'
},
ldap_attr_address: {
$element: $('#ldap_attr_address'),
setMethod: 'setAddressAttribute'
},
ldap_attr_twitter: {
$element: $('#ldap_attr_twitter'),
setMethod: 'setTwitterAttribute'
},
ldap_attr_fediverse: {
$element: $('#ldap_attr_fediverse'),
setMethod: 'setFediverseAttribute'
},
ldap_attr_organisation: {
$element: $('#ldap_attr_organisation'),
setMethod: 'setOrganisationAttribute'
},
ldap_attr_role: {
$element: $('#ldap_attr_role'),
setMethod: 'setRoleAttribute'
},
ldap_attr_headline: {
$element: $('#ldap_attr_headline'),
setMethod: 'setHeadlineAttribute'
},
ldap_attr_biography: {
$element: $('#ldap_attr_biography'),
setMethod: 'setBiographyAttribute'
},
};
this.setManagedItems(items);
},
Expand Down Expand Up @@ -366,6 +404,87 @@ OCA = OCA || {};
this.setElementValue(this.managedItems.home_folder_naming_rule.$element, attribute);
},

/**
* sets the attribute for the Nextcloud user profile phone Number
*
* @param {string} attribute
*/
setPhoneAttribute: function(attribute) {
this.setElementValue(this.managedItems.ldap_attr_phone.$element, attribute);
},

/**
* sets the attribute for the Nextcloud user profile website
*
* @param {string} attribute
*/
setWebsiteAttribute: function(attribute) {
this.setElementValue(this.managedItems.ldap_attr_website.$element, attribute);
},

/**
* sets the attribute for the Nextcloud user profile postal address
*
* @param {string} attribute
*/
setAddressAttribute: function(attribute) {
this.setElementValue(this.managedItems.ldap_attr_address.$element, attribute);
},

/**
* sets the attribute for the Nextcloud user profile twitter
*
* @param {string} attribute
*/
setTwitterAttribute: function(attribute) {
this.setElementValue(this.managedItems.ldap_attr_twitter.$element, attribute);
},

/**
* sets the attribute for the Nextcloud user profile fediverse
*
* @param {string} attribute
*/
setFediverseAttribute: function(attribute) {
this.setElementValue(this.managedItems.ldap_attr_fediverse.$element, attribute);
},

/**
* sets the attribute for the Nextcloud user profile organisation
*
* @param {string} attribute
*/
setOrganisationAttribute: function(attribute) {
this.setElementValue(this.managedItems.ldap_attr_organisation.$element, attribute);
},

/**
* sets the attribute for the Nextcloud user profile role
*
* @param {string} attribute
*/
setRoleAttribute: function(attribute) {
this.setElementValue(this.managedItems.ldap_attr_role.$element, attribute);
},

/**
* sets the attribute for the Nextcloud user profile headline
*
* @param {string} attribute
*/
setHeadlineAttribute: function(attribute) {
this.setElementValue(this.managedItems.ldap_attr_headline.$element, attribute);
},

/**
* sets the attribute for the Nextcloud user profile biography
*
* @param {string} attribute
*/
setBiographyAttribute: function(attribute) {
this.setElementValue(this.managedItems.ldap_attr_biography.$element, attribute);
},

/**
* deals with the result of the Test Connection test
*
Expand Down
28 changes: 28 additions & 0 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lennart Rosam <hello@takuto.de>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Marc Hefter <marchefter@march42.net>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin McCorkell <robin@mccorkell.me.uk>
* @author Roeland Jago Douma <roeland@famdouma.nl>
Expand Down Expand Up @@ -123,6 +124,15 @@ class Configuration {
'ldapExtStorageHomeAttribute' => null,
'ldapMatchingRuleInChainState' => self::LDAP_SERVER_FEATURE_UNKNOWN,
'ldapConnectionTimeout' => 15,
'ldapAttributePhone' => null,
'ldapAttributeWebsite' => null,
'ldapAttributeAddress' => null,
'ldapAttributeTwitter' => null,
'ldapAttributeFediverse' => null,
'ldapAttributeOrganisation' => null,
'ldapAttributeRole' => null,
'ldapAttributeHeadline' => null,
'ldapAttributeBiography' => null,
];

public function __construct(string $configPrefix, bool $autoRead = true) {
Expand Down Expand Up @@ -469,6 +479,15 @@ public function getDefaults(): array {
'ldap_ext_storage_home_attribute' => '',
'ldap_matching_rule_in_chain_state' => self::LDAP_SERVER_FEATURE_UNKNOWN,
'ldap_connection_timeout' => 15,
'ldap_attr_phone' => '',
'ldap_attr_website' => '',
'ldap_attr_address' => '',
'ldap_attr_twitter' => '',
'ldap_attr_fediverse' => '',
'ldap_attr_organisation' => '',
'ldap_attr_role' => '',
'ldap_attr_headline' => '',
'ldap_attr_biography' => '',
];
}

Expand Down Expand Up @@ -535,6 +554,15 @@ public function getConfigTranslationArray(): array {
'ldap_matching_rule_in_chain_state' => 'ldapMatchingRuleInChainState',
'ldapIgnoreNamingRules' => 'ldapIgnoreNamingRules', // sysconfig
'ldap_connection_timeout' => 'ldapConnectionTimeout',
'ldap_attr_phone' => 'ldapAttributePhone',
'ldap_attr_website' => 'ldapAttributeWebsite',
'ldap_attr_address' => 'ldapAttributeAddress',
'ldap_attr_twitter' => 'ldapAttributeTwitter',
'ldap_attr_fediverse' => 'ldapAttributeFediverse',
'ldap_attr_organisation' => 'ldapAttributeOrganisation',
'ldap_attr_role' => 'ldapAttributeRole',
'ldap_attr_headline' => 'ldapAttributeHeadline',
'ldap_attr_biography' => 'ldapAttributeBiography',
];
return $array;
}
Expand Down
9 changes: 9 additions & 0 deletions apps/user_ldap/lib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
* @property int hasMemberOfFilterSupport
* @property int useMemberOfToDetectMembership
* @property string ldapMatchingRuleInChainState
* @property string ldapAttributePhone
* @property string ldapAttributeWebsite
* @property string ldapAttributeAddress
* @property string ldapAttributeTwitter
* @property string ldapAttributeFediverse
* @property string ldapAttributeOrganisation
* @property string ldapAttributeRole
* @property string ldapAttributeHeadline
* @property string ldapAttributeBiography
*/
class Connection extends LDAPUtility {
/**
Expand Down
10 changes: 10 additions & 0 deletions apps/user_ldap/lib/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Marc Hefter <marchefter@march42.net>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Roger Szabo <roger.szabo@web.de>
Expand Down Expand Up @@ -152,6 +153,15 @@ public function getAttributes($minimal = false) {
$this->access->getConnection()->ldapUserDisplayName,
$this->access->getConnection()->ldapUserDisplayName2,
$this->access->getConnection()->ldapExtStorageHomeAttribute,
$this->access->getConnection()->ldapAttributePhone,
$this->access->getConnection()->ldapAttributeWebsite,
$this->access->getConnection()->ldapAttributeAddress,
$this->access->getConnection()->ldapAttributeTwitter,
$this->access->getConnection()->ldapAttributeFediverse,
$this->access->getConnection()->ldapAttributeOrganisation,
$this->access->getConnection()->ldapAttributeRole,
$this->access->getConnection()->ldapAttributeHeadline,
$this->access->getConnection()->ldapAttributeBiography,
];

$homeRule = (string)$this->access->getConnection()->homeFolderNamingRule;
Expand Down
Loading