mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Add a reason to the NotFound exception so we can provide more robust errors
This commit is contained in:
@@ -298,7 +298,7 @@ class IPAdmin(SimpleLDAPObject):
|
||||
raise e
|
||||
except ldap.NO_SUCH_OBJECT, e:
|
||||
args = kw.get('args', '')
|
||||
raise errors.NotFound(msg=notfound(args))
|
||||
raise errors.NotFound(reason=notfound(args))
|
||||
except ldap.ALREADY_EXISTS, e:
|
||||
raise errors.DuplicateEntry()
|
||||
except ldap.CONSTRAINT_VIOLATION, e:
|
||||
@@ -361,7 +361,7 @@ class IPAdmin(SimpleLDAPObject):
|
||||
self.__handle_errors(e, **kw)
|
||||
|
||||
if not obj:
|
||||
raise errors.NotFound(msg=notfound(args))
|
||||
raise errors.NotFound(reason=notfound(args))
|
||||
|
||||
elif isinstance(obj,Entry):
|
||||
return obj
|
||||
@@ -383,7 +383,7 @@ class IPAdmin(SimpleLDAPObject):
|
||||
self.__handle_errors(e, **kw)
|
||||
|
||||
if not obj:
|
||||
raise errors.NotFound(msg=notfound(args))
|
||||
raise errors.NotFound(reason=notfound(args))
|
||||
|
||||
entries = []
|
||||
for s in obj:
|
||||
@@ -421,7 +421,7 @@ class IPAdmin(SimpleLDAPObject):
|
||||
self.__handle_errors(e, **kw)
|
||||
|
||||
if not entries:
|
||||
raise errors.NotFound(msg=notfound(args))
|
||||
raise errors.NotFound(reason=notfound(args))
|
||||
|
||||
if partial == 1:
|
||||
counter = -1
|
||||
|
||||
@@ -270,7 +270,7 @@ def search(base, filter, attributes, timelimit=1, sizelimit=3000, scope=ldap.SCO
|
||||
results = context.ldap.conn.getListAsync(base, scope,
|
||||
filter, attributes, 0, None, None, timelimit, sizelimit)
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
raise errors.NotFound()
|
||||
raise errors.NotFound(reason=filter)
|
||||
|
||||
counter = results[0]
|
||||
entries = [counter]
|
||||
@@ -315,9 +315,9 @@ def get_ipa_config():
|
||||
searchfilter = "cn=ipaconfig"
|
||||
try:
|
||||
config = get_sub_entry("cn=etc," + api.env.basedn, searchfilter)
|
||||
except ldap.NO_SUCH_OBJECT, e:
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
# FIXME
|
||||
raise errors.NotFound()
|
||||
raise errors.NotFound(reason="IPA configuration cannot be loaded")
|
||||
|
||||
return config
|
||||
|
||||
@@ -409,12 +409,12 @@ def add_member_to_group(member_dn, group_dn, memberattr='member'):
|
||||
|
||||
group = get_entry_by_dn(group_dn, None)
|
||||
if group is None:
|
||||
raise errors.NotFound()
|
||||
raise errors.NotFound(reason="cannot find group %s" % group_dn)
|
||||
|
||||
# check to make sure member_dn exists
|
||||
member_entry = get_base_entry(member_dn, "(objectClass=*)", ['dn','objectclass'])
|
||||
if not member_entry:
|
||||
raise errors.NotFound()
|
||||
raise errors.NotFound(reason="cannot find member %s" % member_dn)
|
||||
|
||||
# Add the new member to the group member attribute
|
||||
members = group.get(memberattr, [])
|
||||
@@ -430,7 +430,7 @@ def remove_member_from_group(member_dn, group_dn, memberattr='member'):
|
||||
|
||||
group = get_entry_by_dn(group_dn, None)
|
||||
if group is None:
|
||||
raise errors.NotFound()
|
||||
raise errors.NotFound(reason="cannot find group %s" % group_dn)
|
||||
"""
|
||||
if group.get('cn') == "admins":
|
||||
member = get_entry_by_dn(member_dn, ['dn','uid'])
|
||||
|
||||
Reference in New Issue
Block a user