diff --git a/management/univention-directory-manager-modules/modules/univention/admin/uldap.py b/management/univention-directory-manager-modules/modules/univention/admin/uldap.py index 689d756..fd0f594 100644 --- a/management/univention-directory-manager-modules/modules/univention/admin/uldap.py +++ b/management/univention-directory-manager-modules/modules/univention/admin/uldap.py @@ -85,7 +85,8 @@ def _err2str(err): msgs = [] for iarg in err.args: if isinstance(iarg, dict): - msg = ': '.join([str(m) for m in (iarg.get('desc'), iarg.get('info')) if m]) + matched = 'matched %s' % (iarg['matched'],) if 'matched' in iarg else '' + msg = ': '.join([str(m) for m in (iarg.get('desc'), iarg.get('info'), matched) if m]) else: msg = str(iarg) if msg: @@ -358,7 +359,7 @@ def search(self, filter='(objectClass=*)', base='', scope='sub', attr=[], unique try: return self.lo.search(filter, base, scope, attr, unique, required, timeout, sizelimit) except ldap.NO_SUCH_OBJECT as msg: - raise univention.admin.uexceptions.noObject(_err2str(msg)) + raise univention.admin.uexceptions.noObject(base, _err2str(msg)) except ldap.INAPPROPRIATE_MATCHING as msg: raise univention.admin.uexceptions.insufficientInformation(_err2str(msg)) except (ldap.TIMEOUT, ldap.TIMELIMIT_EXCEEDED) as msg: @@ -374,7 +375,7 @@ def searchDn(self, filter='(objectClass=*)', base='', scope='sub', unique=False, try: return self.lo.searchDn(filter, base, scope, unique, required, timeout, sizelimit) except ldap.NO_SUCH_OBJECT as msg: - raise univention.admin.uexceptions.noObject(_err2str(msg)) + raise univention.admin.uexceptions.noObject(base, _err2str(msg)) except ldap.INAPPROPRIATE_MATCHING as msg: raise univention.admin.uexceptions.insufficientInformation(_err2str(msg)) except (ldap.TIMEOUT, ldap.TIMELIMIT_EXCEEDED) as msg: @@ -407,6 +408,9 @@ def add(self, dn, al, exceptions=False): except ldap.INSUFFICIENT_ACCESS as msg: univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'add dn=%s err=%s' % (dn, msg)) raise univention.admin.uexceptions.permissionDenied + except ldap.NO_SUCH_OBJECT as msg: + univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'add dn=%s err=%s' % (dn, msg)) + raise univention.admin.uexceptions.noObject(dn, _err2str(msg)) except ldap.LDAPError as msg: univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'add dn=%s err=%s' % (dn, msg)) raise univention.admin.uexceptions.ldapError(_err2str(msg), original_exception=msg) @@ -424,7 +428,7 @@ def modify(self, dn, changes, exceptions=False, ignore_license=0): return self.lo.modify(dn, changes) except ldap.NO_SUCH_OBJECT as msg: univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'mod dn=%s err=%s' % (dn, msg)) - raise univention.admin.uexceptions.noObject(dn) + raise univention.admin.uexceptions.noObject(dn, _err2str(msg)) except ldap.INSUFFICIENT_ACCESS as msg: univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'mod dn=%s err=%s' % (dn, msg)) raise univention.admin.uexceptions.permissionDenied @@ -433,8 +437,8 @@ def modify(self, dn, changes, exceptions=False, ignore_license=0): raise univention.admin.uexceptions.ldapError(_err2str(msg), original_exception=msg) def rename(self, dn, newdn, move_childs=0, ignore_license=False): - if not move_childs == 0: - raise univention.admin.uexceptions.noObject(_("Moving children is not supported.")) + if move_childs: + raise univention.admin.uexceptions.noObject(dn, _("Moving children is not supported.")) self._validateLicense() if not self.allow_modify and not ignore_license: univention.debug.debug(univention.debug.ADMIN, univention.debug.WARN, 'move dn: %s' % dn) @@ -445,7 +449,7 @@ def rename(self, dn, newdn, move_childs=0, ignore_license=False): return self.lo.rename(dn, newdn) except ldap.NO_SUCH_OBJECT as msg: univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'ren dn=%s err=%s' % (dn, msg)) - raise univention.admin.uexceptions.noObject(dn) + raise univention.admin.uexceptions.noObject(dn, _err2str(msg)) except ldap.INSUFFICIENT_ACCESS as msg: univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'ren dn=%s err=%s' % (dn, msg)) raise univention.admin.uexceptions.permissionDenied @@ -465,7 +469,7 @@ def delete(self, dn, exceptions=False): return self.lo.delete(dn) except ldap.NO_SUCH_OBJECT as msg: univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'del dn=%s err=%s' % (dn, msg)) - raise univention.admin.uexceptions.noObject(dn) + raise univention.admin.uexceptions.noObject(dn, _err2str(msg)) except ldap.INSUFFICIENT_ACCESS as msg: univention.debug.debug(univention.debug.LDAP, univention.debug.ALL, 'del dn=%s err=%s' % (dn, msg)) raise univention.admin.uexceptions.permissionDenied