Enforce netgroup uniqueness, allow netgroups to be members of netgroups

When adding an entry, convert a constraint violation of "already exists"
into a DuplicateEntry exception so the user gets a useful response
This commit is contained in:
Rob Crittenden
2009-02-25 13:50:43 -05:00
parent af0c0c309d
commit 3fdf9abfce
3 changed files with 51 additions and 5 deletions

View File

@@ -381,6 +381,12 @@ class IPAdmin(SimpleLDAPObject):
self.add_s(*args)
except ldap.ALREADY_EXISTS, e:
raise errors2.DuplicateEntry
except ldap.CONSTRAINT_VIOLATION, e:
# This error gets thrown by the uniqueness plugin
if e.args[0].get('info','') == 'Another entry with the same attribute value already exists':
raise errors2.DuplicateEntry
else:
raise errors.DatabaseError, e
except ldap.LDAPError, e:
raise errors.DatabaseError, e
return True