mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-09-03 20:52:56 -05:00
Make timelimit a parameter to the find methods.
This commit is contained in:
@@ -109,11 +109,11 @@ class IPAClient:
|
|||||||
result = self.transport.get_add_schema()
|
result = self.transport.get_add_schema()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def find_users(self, criteria, sattrs=None, searchlimit=0):
|
def find_users(self, criteria, sattrs=None, searchlimit=0, timelimit=-1):
|
||||||
"""Return a list: counter followed by a User object for each user that
|
"""Return a list: counter followed by a User object for each user that
|
||||||
matches the criteria. If the results are truncated, counter will
|
matches the criteria. If the results are truncated, counter will
|
||||||
be set to -1"""
|
be set to -1"""
|
||||||
result = self.transport.find_users(criteria, sattrs, searchlimit)
|
result = self.transport.find_users(criteria, sattrs, searchlimit, timelimit)
|
||||||
counter = result[0]
|
counter = result[0]
|
||||||
|
|
||||||
users = [counter]
|
users = [counter]
|
||||||
@@ -193,10 +193,10 @@ class IPAClient:
|
|||||||
result = self.transport.add_group(group_dict, group_container)
|
result = self.transport.add_group(group_dict, group_container)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def find_groups(self, criteria, sattrs=None, searchlimit=0):
|
def find_groups(self, criteria, sattrs=None, searchlimit=0, timelimit=-1):
|
||||||
"""Find groups whose cn matches the criteria. Wildcards are
|
"""Find groups whose cn matches the criteria. Wildcards are
|
||||||
acceptable. Returns a list of Group objects."""
|
acceptable. Returns a list of Group objects."""
|
||||||
result = self.transport.find_groups(criteria, sattrs, searchlimit)
|
result = self.transport.find_groups(criteria, sattrs, searchlimit, timelimit)
|
||||||
counter = result[0]
|
counter = result[0]
|
||||||
|
|
||||||
groups = [counter]
|
groups = [counter]
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class RPCClient:
|
|||||||
|
|
||||||
return ipautil.unwrap_binary_data(result)
|
return ipautil.unwrap_binary_data(result)
|
||||||
|
|
||||||
def find_users (self, criteria, sattrs=None, searchlimit=0):
|
def find_users (self, criteria, sattrs=None, searchlimit=0, timelimit=-1):
|
||||||
"""Return a list: counter followed by a User object for each user that
|
"""Return a list: counter followed by a User object for each user that
|
||||||
matches the criteria. If the results are truncated, counter will
|
matches the criteria. If the results are truncated, counter will
|
||||||
be set to -1"""
|
be set to -1"""
|
||||||
@@ -177,7 +177,7 @@ class RPCClient:
|
|||||||
# None values are not allowed in XML-RPC
|
# None values are not allowed in XML-RPC
|
||||||
if sattrs is None:
|
if sattrs is None:
|
||||||
sattrs = "__NONE__"
|
sattrs = "__NONE__"
|
||||||
result = server.find_users(criteria, sattrs, searchlimit)
|
result = server.find_users(criteria, sattrs, searchlimit, timelimit)
|
||||||
except xmlrpclib.Fault, fault:
|
except xmlrpclib.Fault, fault:
|
||||||
raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
|
raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
|
||||||
except socket.error, (value, msg):
|
except socket.error, (value, msg):
|
||||||
@@ -309,7 +309,7 @@ class RPCClient:
|
|||||||
except socket.error, (value, msg):
|
except socket.error, (value, msg):
|
||||||
raise xmlrpclib.Fault(value, msg)
|
raise xmlrpclib.Fault(value, msg)
|
||||||
|
|
||||||
def find_groups (self, criteria, sattrs=None, searchlimit=0):
|
def find_groups (self, criteria, sattrs=None, searchlimit=0, timelimit=-1):
|
||||||
"""Return a list containing a Group object for each group that matches
|
"""Return a list containing a Group object for each group that matches
|
||||||
the criteria."""
|
the criteria."""
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ class RPCClient:
|
|||||||
# None values are not allowed in XML-RPC
|
# None values are not allowed in XML-RPC
|
||||||
if sattrs is None:
|
if sattrs is None:
|
||||||
sattrs = "__NONE__"
|
sattrs = "__NONE__"
|
||||||
result = server.find_groups(criteria, sattrs, searchlimit)
|
result = server.find_groups(criteria, sattrs, searchlimit, timelimit)
|
||||||
except xmlrpclib.Fault, fault:
|
except xmlrpclib.Fault, fault:
|
||||||
raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
|
raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
|
||||||
except socket.error, (value, msg):
|
except socket.error, (value, msg):
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ class Root(controllers.RootController):
|
|||||||
uid = kw.get('uid')
|
uid = kw.get('uid')
|
||||||
if uid != None and len(uid) > 0:
|
if uid != None and len(uid) > 0:
|
||||||
try:
|
try:
|
||||||
users = client.find_users(uid.encode('utf-8'))
|
users = client.find_users(uid.encode('utf-8'), None, 0, 2)
|
||||||
counter = users[0]
|
counter = users[0]
|
||||||
users = users[1:]
|
users = users[1:]
|
||||||
if counter == -1:
|
if counter == -1:
|
||||||
@@ -596,7 +596,7 @@ class Root(controllers.RootController):
|
|||||||
criteria = kw.get('criteria')
|
criteria = kw.get('criteria')
|
||||||
if criteria != None and len(criteria) > 0:
|
if criteria != None and len(criteria) > 0:
|
||||||
try:
|
try:
|
||||||
groups = client.find_groups(criteria.encode('utf-8'))
|
groups = client.find_groups(criteria.encode('utf-8'), None, 0, 2)
|
||||||
counter = groups[0]
|
counter = groups[0]
|
||||||
groups = groups[1:]
|
groups = groups[1:]
|
||||||
if counter == -1:
|
if counter == -1:
|
||||||
|
|||||||
@@ -448,13 +448,11 @@ class IPAServer:
|
|||||||
|
|
||||||
return users
|
return users
|
||||||
|
|
||||||
def find_users (self, criteria, sattrs=None, searchlimit=0, opts=None):
|
def find_users (self, criteria, sattrs=None, searchlimit=0, timelimit=-1,
|
||||||
|
opts=None):
|
||||||
"""Returns a list: counter followed by the results.
|
"""Returns a list: counter followed by the results.
|
||||||
If the results are truncated, counter will be set to -1."""
|
If the results are truncated, counter will be set to -1."""
|
||||||
|
|
||||||
# TODO - retrieve from config
|
|
||||||
timelimit = 2
|
|
||||||
|
|
||||||
# Assume the list of fields to search will come from a central
|
# Assume the list of fields to search will come from a central
|
||||||
# configuration repository. A good format for that would be
|
# configuration repository. A good format for that would be
|
||||||
# a comma-separated list of fields
|
# a comma-separated list of fields
|
||||||
@@ -664,14 +662,12 @@ class IPAServer:
|
|||||||
finally:
|
finally:
|
||||||
self.releaseConnection(conn)
|
self.releaseConnection(conn)
|
||||||
|
|
||||||
def find_groups (self, criteria, sattrs=None, searchlimit=0, opts=None):
|
def find_groups (self, criteria, sattrs=None, searchlimit=0, timelimit=-1,
|
||||||
|
opts=None):
|
||||||
"""Return a list containing a User object for each
|
"""Return a list containing a User object for each
|
||||||
existing group that matches the criteria.
|
existing group that matches the criteria.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO - retrieve from config
|
|
||||||
timelimit = 2
|
|
||||||
|
|
||||||
# Assume the list of fields to search will come from a central
|
# Assume the list of fields to search will come from a central
|
||||||
# configuration repository. A good format for that would be
|
# configuration repository. A good format for that would be
|
||||||
# a comma-separated list of fields
|
# a comma-separated list of fields
|
||||||
|
|||||||
Reference in New Issue
Block a user