diff options
author | Thorsten Scherf <tscherf@redhat.com> | 2014-08-26 19:21:29 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2014-09-02 10:40:12 +0200 |
commit | a2eab057d4adfaa8da7fee07410e1a33efb7f95d (patch) | |
tree | 8220f2855de348f372734c3ba865e580c52b1131 | |
parent | 90227f817eb27d0d4308b22f8dcf028dc2925689 (diff) | |
download | freeipa-a2eab057d4adfaa8da7fee07410e1a33efb7f95d.tar.gz freeipa-a2eab057d4adfaa8da7fee07410e1a33efb7f95d.tar.xz freeipa-a2eab057d4adfaa8da7fee07410e1a33efb7f95d.zip |
pwpolicy-add: Added better error handling
Make error message more meaningful when a password policy is added for a non
existing group.
https://fedorahosted.org/freeipa/ticket/4334
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
-rw-r--r-- | ipalib/plugins/pwpolicy.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ipalib/plugins/pwpolicy.py b/ipalib/plugins/pwpolicy.py index 1976675c5..165d54889 100644 --- a/ipalib/plugins/pwpolicy.py +++ b/ipalib/plugins/pwpolicy.py @@ -159,9 +159,14 @@ class cosentry_add(LDAPCreate): def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): assert isinstance(dn, DN) + # check for existence of the group group_dn = self.api.Object.group.get_dn(keys[-1]) - result = ldap.get_entry(group_dn, ['objectclass']) + try: + result = ldap.get_entry(group_dn, ['objectclass']) + except errors.NotFound: + self.api.Object.group.handle_not_found(keys[-1]) + oc = map(lambda x:x.lower(),result['objectclass']) if 'mepmanagedentry' in oc: raise errors.ManagedPolicyError() |