summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorThorsten Scherf <tscherf@redhat.com>2014-08-26 19:21:29 +0200
committerMartin Kosek <mkosek@redhat.com>2014-09-02 10:40:12 +0200
commita2eab057d4adfaa8da7fee07410e1a33efb7f95d (patch)
tree8220f2855de348f372734c3ba865e580c52b1131 /ipalib
parent90227f817eb27d0d4308b22f8dcf028dc2925689 (diff)
downloadfreeipa-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>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/pwpolicy.py7
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()