Univention Bugzilla – Bug 41243
normalize username, firstname, lastname, email address when importing users
Last modified: 2016-09-30 11:57:45 CEST
* Use univention.admin.property → _replace() so the syntax from user-templates can be used. * Additionally replace the following strings for name clashes: ** [ALWAYSCOUNTER] ==> anton1, anton2, anton3 ** [COUNTER2] ==> anton, anton2, anton3 * usernames may have different schemes for different user roles
After formatting from scheme, usernames shall be shortened to 12 characters and have the mentioned numbers (counter) appended.
(In reply to Daniel Tröder from comment #1) > After formatting from scheme, usernames shall be shortened to 12 characters > and have the mentioned numbers (counter) appended. This is done, to ensure that the usernames are usually not longer than 15 characters, so they do not exceed 20 characters if the "exam-" prefix is prepended. Otherwise windows will have problem with the username length.
Implemented in r69557 as described in comment #1. The maximum username length can be changed by code or subclasses by changing the attribute ImportUser.username_max_length. Defaults to 15.
(In reply to Daniel Tröder from comment #3) > The maximum username length can be changed by code or subclasses by changing > the attribute ImportUser.username_max_length. Defaults to 15. Do not hardcode the length to 15. Other code parts of UCS@school use something like this: --- a/ucs-school-4.1r2/ucs-school-import/modules/ucsschool/importer/models/import_user.py +++ b/ucs-school-4.1r2/ucs-school-import/modules/ucsschool/importer/models/import_user.py @@ -67,7 +67,7 @@ class ImportUser(User): record_uid = RecordUID("RecordUID") config = None - username_max_length = 15 + username_max_length = None _unique_ids = defaultdict(set) factory = None ucr = None @@ -84,6 +84,8 @@ class ImportUser(User): self.ucr = self.factory.make_ucr() self.config = Configuration() self.reader = self.factory.make_reader() + if self.username_max_length is None: + self.username_max_length = 20 - len(self.ucr.get('ucsschool/ldap/default/userprefix/exam', 'exam-')) super(ImportUser, self).__init__(name, school, **kwargs) def build_hook_line(self, hook_time, func_name):
(In reply to Sönke Schwardt-Krummrich from comment #4) > Do not hardcode the length to 15 Fixed in r70131.
(In reply to Daniel Tröder from comment #5) > (In reply to Sönke Schwardt-Krummrich from comment #4) > > Do not hardcode the length to 15 > Fixed in r70131. → r70131 verified
[ALWAYSCOUNTER] and [COUNTER2] are covered by 34_import-users_via_cli_v2. Missing is currently a test, that the usernames are not reused if a previous user has been removed.
(In reply to Sönke Schwardt-Krummrich from comment #7) > [ALWAYSCOUNTER] and [COUNTER2] are covered by 34_import-users_via_cli_v2. > > Missing is currently a test, that the usernames are not reused if a previous > user has been removed. That was meant for bug 41244.