How-To: Changing the Username - Best Practices for Updating Login Names, Paths, and Scripts

Problem

In UCS@school environments, usernames often follow a standardized format derived from users’ last names. However, when last names change, usernames, Samba directories, and login scripts may require updates. Managing these changes manually can lead to inconsistencies and potential issues, especially if an automated import system is in place that relies on unique usernames and counters to prevent duplication.

Solution

The following steps guide you through modifying the username using Univention Directory Manager (UDM) and updating necessary LDAP entries.

  1. Check if the new username exists
    Before making any changes, verify if the desired username is available. This is critical to avoid potential conflicts in the system.

  2. Modify user attributes with UDM
    To change the username, follow the example below, replacing details as needed. In this case, the lastname will be changed from Eimers to Meyer:

    udm users/user modify \
    --dn uid=user.eimer,cn=schueler,cn=users,ou=Schule01,$(ucr get ldap/base) \
    --set lastname=Meyer \
    --set username=user.meyer \
    --set displayName='User Meyer' \
    --set sambahome='\\Schule01\user.meyer' \
    --set unixhome='/home/Schule01/schueler/user.meyer' \
    --set scriptpath=user-meyer.vbs
    
    • Ensure proper use of quotation marks for paths, especially for sambahome, to interpret backslashes correctly.
    • Some additional attributes may also be affected and may require updates. For example: mailPrimaryAddress, email, and homeSharePath.
  3. Update unique username entries in LDAP (if required)
    If the system uses an increment counter to ensure unique usernames, add the new username to the unique usernames list in LDAP. This prevents conflicts if another user with the same initial username format is added later:

    ldapadd -x -D "cn=admin,$(ucr get ldap/base)" -y /etc/ldap.secret <<EOR
    dn: cn=user.meyer,cn=unique-usernames,cn=ucsschool,cn=univention,dc=schule,dc=intranet
    objectClass: ucsschoolUsername
    ucsschoolUsernameNextNumber: 2
    cn: user.meyer
    EOR
    

    Here, ucsschoolUsernameNextNumber represents the counter for the username. Set this number according to your import system’s requirements to avoid conflicts.

  4. Verify changes
    After applying these modifications, check that the user can log in with the updated username and that all paths and scripts work as expected.

This topic was automatically closed after 24 hours. New replies are no longer allowed.