Univention Bugzilla – Bug 41472
Support for auto-generated attributes
Last modified: 2016-09-30 12:43:38 CEST
Currently, only the username attribute can be auto-generated according to a specified scheme. Other attributes need to be auto-generated as well like e-mail addresses. In general, it would be very good if there were a mechanism that would make auto-generation of attribute values as easy a possible by reducing it to the JSON configuration for simple attributes.
The email address is also created like the username from a scheme (manual-4.1:users:templates). Configuration key is config["scheme"]["email"] (see /usr/share/doc/ucs-school-import/configuration_readme.txt.gz). But a generic mechanism has been implemented: To support arbitrary interpretation of user input, overwrite reader.csv_reader.CsvReader.handle_input(). See itself or legacy.legacy_csv_reader.LegacyCsvReader.handle_input() as an example. The format string can optionally be added to the config-file: "scheme": {"birthday": "30.<month>1976"} In handle_input() the transformations can be made by hand, or comfortably by accessing the functionality of users:templates, calling birthday = myImportUser.format_from_scheme("birthday", config["scheme"]["birthday"], **kwargs) with kwargs={"month": "02"}. I will add a routine that will check for every target except ["sourceUID", "source_uid", "__*"] of the user input mapping in config["csv"]["mapping"], if a scheme exists in config["scheme"] and apply it automatically.
r69873: In configuration["scheme"][<udm attribute name>] schemes (manual-4.1:users:templates) can be configured. When adding/modifying users, UDM attributes will be created/modified from them in ImportUser.prepare_udm_properties(). ucsschool.lib.Attributes are ignored in prepare_udm_properties(), as they are processed separately in ImportUser.make_*(). The following Attributes of User are handled in make_*() methods: birthday, firstname, lastname, email, record_uid and (user)name. For them and the UDM attributes the replacement <variables> are filled in the following oder (later additions overwriting previous ones): - from "raw" input data (as stored in ImportUser.input_data) - from ucsschool.lib.Attributes of self (ImportUser & ucsschool.lib.models.user.User) - from self.udm_properties - from kwargs to format_from_scheme() An example: an import with the following addition to ["scheme"] in configs/legacy.json: { "scheme": { .., .., "phone": "030-<firstname>12<:lower>", "description": "My email address is <email> and my RID is <record_uid>." } } # /usr/share/ucs-school-import/scripts/import_user /tmp/importtest .. # univention-ldapsearch -xLLL '(|(ucsschoolSourceUID=*)(ucsschoolRecordUID=*))' ucsschoolSchool ucsschoolSourceUID ucsschoolRecordUID telephoneNumber description .. dn: uid=vhohfgizqg,cn=lehrer und mitarbeiter,cn=users,ou=schule2,dc=uni,dc=dtr ucsschoolRecordUID: vhohfgizqg ucsschoolSchool: schule2 ucsschoolSourceUID: LegacyDB description: My email address is vhohfgizqg@uni.dtr and my RID is vhohfgizqg. telephoneNumber: 030-dycfmghr0c12
ucs-test-ucsschool (3.0.12-4): r70236 | Bug #41472: added test for auto-generated attribute values in 34_import-users_via_cli_v2 → verified
UCS@school 4.1 R2 has been released: http://docs.software-univention.de/release-notes-ucsschool-4.1R2v1-de.pdf If this error occurs again, please use "Clone This Bug".