summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/user.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2010-12-13 09:53:29 -0500
committerRob Crittenden <rcritten@redhat.com>2010-12-13 09:53:29 -0500
commitba8d21f5ae3d4133032c635dad77127cb72ab1bf (patch)
treef12e55142e1a796c895a4f6f23249c07f4e47af3 /ipalib/plugins/user.py
parente8157f262835ce7232907a43a8d1dc4d4e6ea10d (diff)
downloadfreeipa-ba8d21f5ae3d4133032c635dad77127cb72ab1bf.tar.gz
freeipa-ba8d21f5ae3d4133032c635dad77127cb72ab1bf.tar.xz
freeipa-ba8d21f5ae3d4133032c635dad77127cb72ab1bf.zip
Check for existence of the group when adding a user.
The Managed Entries plugin will allow a user to be added even if a group of the same name exists. This would leave the user without a private group. We need to check for both the user and the group so we can do 1 of 3 things: - throw an error that the group exists (but not the user) - throw an error that the user exists (and the group) - allow the uesr to be added ticket 567
Diffstat (limited to 'ipalib/plugins/user.py')
-rw-r--r--ipalib/plugins/user.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index c3246f5cd..283c0c416 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -211,6 +211,18 @@ class user_add(LDAPCreate):
msg_summary = _('Added user "%(value)s"')
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
+ try:
+ # The Managed Entries plugin will allow a user to be created
+ # even if a group has a duplicate name. This would leave a user
+ # without a private group. Check for both the group and the user.
+ self.api.Command['group_show'](keys[-1])
+ try:
+ self.api.Command['user_show'](keys[-1])
+ raise errors.DuplicateEntry()
+ except errors.NotFound:
+ raise errors.ManagedGroupExistsError(group=keys[-1])
+ except errors.NotFound:
+ pass
config = ldap.get_ipa_config()[1]
if 'ipamaxusernamelength' in config:
if len(keys[-1]) > int(config.get('ipamaxusernamelength')[0]):