Problem: DryRun of API import creates a new user instead of adding a number

Problem

In the DryRun, new students should be created who already exist. Then the importer should supplement the user with an appended number. So “schueler” becomes “schueler2”. But this does not work in DryRun, the importer deactivates the old user and tries to create a new user with the same name.

Environment

If users have been created MANUALLY, they do not yet have a COUNTER field, which prevents the importer from incrementing them. Thus the importer does not consider the user as “countable” and tries to create a new one.

Solution

Manually add the COUNTER field to the affected users. Please note, that NEXTFREENUMBER must be an integer and the value has to be 2 or higher. Negative values and also 0 and 1 are NOT valid!

export USERNAME=user.name
export NEXTFREENUMBER=2
python -c "from ucsschool.importer.utils.username_handler import LdapStorageBackend; b = LdapStorageBackend('usernames'); b.create('${USERNAME}', ${NEXTFREENUMBER})"

In case a user has been marked by accident with the COUNTER field you can remove this value as follows:

export USERNAME=user.name
export NEXTFREENUMBER=""
python -c "from ucsschool.importer.utils.username_handler import LdapStorageBackend; b = LdapStorageBackend('usernames'); b.create('${USERNAME}', ${NEXTFREENUMBER})"
Mastodon