diff options
author | Petr Viktorin <pviktori@redhat.com> | 2013-01-21 08:39:09 -0500 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2013-03-01 16:59:45 +0100 |
commit | 4779865ea30dba0b5f0594cdc4633b0cc93bf36a (patch) | |
tree | 17708b9facca822d26570de65cd691e12bf3eeff /ipaserver/ipaldap.py | |
parent | f5c404c65d81d9a28f171fabe7c5749d6c37f102 (diff) | |
download | freeipa.git-4779865ea30dba0b5f0594cdc4633b0cc93bf36a.tar.gz freeipa.git-4779865ea30dba0b5f0594cdc4633b0cc93bf36a.tar.xz freeipa.git-4779865ea30dba0b5f0594cdc4633b0cc93bf36a.zip |
Replace getList by a get_entries method
The find_entries method is cumbersome to use: it requires keyword arguments
for simple uses, and callers are tempted to ignore the 'truncated' flag
it returns.
Introduce a simpler method, get_entries, that returns the found
list directly, and raises an errors if the list is truncated.
Replace the getList method by get_entries.
Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Diffstat (limited to 'ipaserver/ipaldap.py')
-rw-r--r-- | ipaserver/ipaldap.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py index 7fceb889..78021201 100644 --- a/ipaserver/ipaldap.py +++ b/ipaserver/ipaldap.py @@ -1069,6 +1069,24 @@ class LDAPConnection(object): ) return self.combine_filters(flts, rules) + def get_entries(self, base_dn, scope=None, filter=None, attrs_list=None): + """Return a list of matching entries. + + Raises an error if the list is truncated by the server + + :param base_dn: dn of the entry at which to start the search + :param scope: search scope, see LDAP docs (default ldap2.SCOPE_SUBTREE) + :param filter: LDAP filter to apply + :param attrs_list: ist of attributes to return, all if None (default) + + Use the find_entries method for more options. + """ + entries, truncated = self.find_entries( + base_dn=base_dn, scope=scope, filter=filter, attrs_list=attrs_list) + if truncated: + raise errors.LimitsExceeded() + return entries + def find_entries(self, filter=None, attrs_list=None, base_dn=None, scope=_ldap.SCOPE_SUBTREE, time_limit=None, size_limit=None, normalize=True, search_refs=False): @@ -1629,16 +1647,6 @@ class IPAdmin(LDAPConnection): ) return result[0] - def getList(self, base, scope, filterstr='(objectClass=*)', attrlist=None): - # FIXME: for backwards compatibility only - result, truncated = self.find_entries( - filter=filterstr, - attrs_list=attrlist, - base_dn=base, - scope=scope, - ) - return result - def addEntry(self, entry): # FIXME: for backwards compatibility only self.add_entry(entry.dn, entry) |