From 2b38769b50b51d28111a07be86d9fc70e5b6b8f5 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 9 Oct 2007 09:26:16 -0700 Subject: Combine get_user/group by dn/cn into get_entry_by_cn/dn. Also a couple double-escaping fixes I missed in the last patch. --- ipa-python/rpcclient.py | 67 ++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 40 deletions(-) (limited to 'ipa-python/rpcclient.py') diff --git a/ipa-python/rpcclient.py b/ipa-python/rpcclient.py index d0b0c227..8bc288b4 100644 --- a/ipa-python/rpcclient.py +++ b/ipa-python/rpcclient.py @@ -66,26 +66,45 @@ class RPCClient: obj[k] = ent[k] return obj - -# User support - def get_user_by_uid(self,uid,sattrs=None): - """Get a specific user. If sattrs is not None then only those +# General searches + + def get_entry_by_dn(self,dn,sattrs=None): + """Get a specific entry. If sattrs is not None then only those attributes will be returned, otherwise all available attributes are returned. The result is a dict.""" server = self.setup_server() if sattrs is None: sattrs = "__NONE__" try: - result = server.get_user_by_uid(uid, sattrs) + result = server.get_entry_by_dn(dn, sattrs) except xmlrpclib.Fault, fault: raise ipaerror.gen_exception(fault.faultCode, fault.faultString) except socket.error, (value, msg): raise xmlrpclib.Fault(value, msg) return ipautil.unwrap_binary_data(result) - - def get_user_by_dn(self,dn,sattrs=None): + + def get_entry_by_cn(self,cn,sattrs=None): + """Get a specific entry by cn. If sattrs is not None then only those + attributes will be returned, otherwise all available + attributes are returned. The result is a dict.""" + server = self.setup_server() + if sattrs is None: + sattrs = "__NONE__" + try: + result = server.get_entry_by_cn(cn, sattrs) + except xmlrpclib.Fault, fault: + raise ipaerror.gen_exception(fault.faultCode, fault.faultString) + except socket.error, (value, msg): + raise xmlrpclib.Fault(value, msg) + + return ipautil.unwrap_binary_data(result) + + +# User support + + def get_user_by_uid(self,uid,sattrs=None): """Get a specific user. If sattrs is not None then only those attributes will be returned, otherwise all available attributes are returned. The result is a dict.""" @@ -93,7 +112,7 @@ class RPCClient: if sattrs is None: sattrs = "__NONE__" try: - result = server.get_user_by_dn(dn, sattrs) + result = server.get_user_by_uid(uid, sattrs) except xmlrpclib.Fault, fault: raise ipaerror.gen_exception(fault.faultCode, fault.faultString) except socket.error, (value, msg): @@ -258,38 +277,6 @@ class RPCClient: return ipautil.unwrap_binary_data(result) # Group support - - def get_group_by_cn(self,cn,sattrs=None): - """Get a specific group. If sattrs is not None then only those - attributes will be returned, otherwise all available - attributes are returned. The result is a dict.""" - server = self.setup_server() - if sattrs is None: - sattrs = "__NONE__" - try: - result = server.get_group_by_cn(cn, sattrs) - except xmlrpclib.Fault, fault: - raise ipaerror.gen_exception(fault.faultCode, fault.faultString) - except socket.error, (value, msg): - raise xmlrpclib.Fault(value, msg) - - return ipautil.unwrap_binary_data(result) - - def get_group_by_dn(self,dn,sattrs=None): - """Get a specific group. If sattrs is not None then only those - attributes will be returned, otherwise all available - attributes are returned. The result is a dict.""" - server = self.setup_server() - if sattrs is None: - sattrs = "__NONE__" - try: - result = server.get_group_by_dn(dn, sattrs) - except xmlrpclib.Fault, fault: - raise ipaerror.gen_exception(fault.faultCode, fault.faultString) - except socket.error, (value, msg): - raise xmlrpclib.Fault(value, msg) - - return ipautil.unwrap_binary_data(result) def get_groups_by_member(self,member_dn,sattrs=None): """Gets the groups that member_dn belongs to. -- cgit