Bug 37821 - CSV import should not create overlong or invalid usernames
CSV import should not create overlong or invalid usernames
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: UMC - CSV Import
UCS@school 4.0
Other Linux
: P5 normal (vote)
: UCS@school 4.0 Errata
Assigned To: Florian Best
Alexander Kramer
:
Depends on:
Blocks: 37822
  Show dependency treegraph
 
Reported: 2015-02-17 11:13 CET by Sönke Schwardt-Krummrich
Modified: 2015-02-27 15:19 CET (History)
0 users

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Schwardt-Krummrich univentionstaff 2015-02-17 11:13:43 CET
Currently the CSV import assembles autocreated usernames by attaching first name, dot and last name. If invalid characters are present in first or last name the following syntax will complain about the invalid username.
This is also the case if the resulting username is longer than 15 characters (20 character limitation for samAccountName minus "exam-"). The syntax check will complain, too.
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2015-02-17 11:16:54 CET
The generated usernames should 
- contain only valid characters
- be not too long
- be unique
- reproducible (same user generates same username during another import)
(if possible, otherwise it produces new errors).
Comment 2 Florian Best univentionstaff 2015-02-20 15:12:58 CET
Invalid character are stripped now.
Username consists of firstname and lastname stripped at 5 characters, stipped at 20 - len(exam-prefix).
Old behavior can be achieved by UCR variable ucsschool/csvimport/username/generation/firstname_lastname.

TODO: doku, release notes, etc.
Comment 3 Sönke Schwardt-Krummrich univentionstaff 2015-02-20 17:04:18 CET
Please set ucsschool/csvimport/username/generation/firstname_lastname=true in postinst script during update (not during fresh installations!).

I would suggest the following addon patch:
--- a/ucs-school-4.0/ucs-school-umc-csv-import/umc/python/schoolcsvimport/util.py
+++ b/ucs-school-4.0/ucs-school-umc-csv-import/umc/python/schoolcsvimport/util.py
@@ -104,12 +104,12 @@ class CSVUser(User):
 		if self.lastname:
 			lastname = u'%s' % (self.lastname.split()[-1].lower())
 
-		if ucr.is_true('ucsschool/csvimport/username/generation/firstname_lastname', False):
-			return firstname + (u'.' if firstname else u'') + lastname
-
 		firstname = self.RE_UID_INVALID.sub('', firstname)
 		lastname = self.RE_UID_INVALID.sub('', lastname)
 
+		if ucr.is_true('ucsschool/csvimport/username/generation/firstname_lastname', False):
+			return firstname + (u'.' if firstname else u'') + lastname
+
 		if firstname:
 			firstname = firstname[:5] + '.'


Otherwise invalid characters will not be removed if old username format is used.
Comment 4 Florian Best univentionstaff 2015-02-24 09:49:59 CET
* Changelog added
* postinst adapted
* adapted patch from comment #3 applied

Packages are currently building.
Comment 5 Alexander Kramer univentionstaff 2015-02-25 12:57:27 CET
OK - debian/changelog
OK - changelog
OK - username 
-- contain only valid charactersbe
-- not too long
-- be unique
-- reproducible
Comment 6 Sönke Schwardt-Krummrich univentionstaff 2015-02-27 15:19:36 CET
UCS@school 4.0 v2 has been released:
http://docs.univention.de/release-notes-ucsschool-4.0v2-de.html

If this error occurs again, please use "Clone This Bug".