diff options
author | Florence Blanc-Renaud <frenaud@redhat.com> | 2016-06-08 18:09:15 +0200 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2016-06-09 14:31:40 +0200 |
commit | 53524fbbff51418a8f1194c8559c9dcfcc5bbb83 (patch) | |
tree | f293a98ac789e39bda9a77ae4ce66c831f683020 /ipapython/ipaldap.py | |
parent | aa734da49440c5d12c0f8d4566505adaeef254e8 (diff) | |
download | freeipa-53524fbbff51418a8f1194c8559c9dcfcc5bbb83.tar.gz freeipa-53524fbbff51418a8f1194c8559c9dcfcc5bbb83.tar.xz freeipa-53524fbbff51418a8f1194c8559c9dcfcc5bbb83.zip |
add context to exception on LdapEntry decode error
When reading the content of an invalid LDAP entry, the exception
only displays the attribute name and value, but not the DN of the entry.
Because of this, it is difficult to identify the root cause of the
problem.
The fix raises a ValueError exception which also contains the entry DN.
https://fedorahosted.org/freeipa/ticket/5434
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
Diffstat (limited to 'ipapython/ipaldap.py')
-rw-r--r-- | ipapython/ipaldap.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index 9fb7fd3f5..410ddae2c 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -308,7 +308,11 @@ class LDAPEntry(collections.MutableMapping): raw.remove(value) for value in raw_dels: - value = self._conn.decode(value, name) + try: + value = self._conn.decode(value, name) + except ValueError as e: + raise ValueError("{error} in LDAP entry '{dn}'".format( + error=e, dn=self._dn)) if value in nice_adds: continue nice.remove(value) @@ -320,7 +324,11 @@ class LDAPEntry(collections.MutableMapping): raw.append(value) for value in raw_adds: - value = self._conn.decode(value, name) + try: + value = self._conn.decode(value, name) + except ValueError as e: + raise ValueError("{error} in LDAP entry '{dn}'".format( + error=e, dn=self._dn)) if value in nice_dels: continue nice.append(value) |