mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-26 17:01:14 -06:00
Check configured maximum user login length on user rename.
ticket 2587
This commit is contained in:
parent
7471ba2237
commit
dcea80fc17
@ -551,6 +551,16 @@ class user_mod(LDAPUpdate):
|
||||
has_output_params = LDAPUpdate.has_output_params + user_output_params
|
||||
|
||||
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
|
||||
if 'rename' in options:
|
||||
config = ldap.get_ipa_config()[1]
|
||||
if 'ipamaxusernamelength' in config:
|
||||
if len(options['rename']) > int(config.get('ipamaxusernamelength')[0]):
|
||||
raise errors.ValidationError(
|
||||
name=self.obj.primary_key.cli_name,
|
||||
error=_('can be at most %(len)d characters') % dict(
|
||||
len = int(config.get('ipamaxusernamelength')[0])
|
||||
)
|
||||
)
|
||||
if 'mail' in entry_attrs:
|
||||
entry_attrs['mail'] = self.obj._normalize_email(entry_attrs['mail'])
|
||||
if 'manager' in entry_attrs:
|
||||
|
@ -685,6 +685,13 @@ class test_user(Declarative):
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Try to rename to a username that is too long %r' % user1,
|
||||
command=('user_mod', [user1], dict(rename=invaliduser2)),
|
||||
expected=errors.ValidationError(name='uid', error='can be at most 33 characters'),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Create %r' % group1,
|
||||
command=(
|
||||
|
Loading…
Reference in New Issue
Block a user