diff options
Diffstat (limited to 'ipa-server')
-rw-r--r-- | ipa-server/ipaserver/ipaldap.py | 10 | ||||
-rw-r--r-- | ipa-server/xmlrpc-server/funcs.py | 39 | ||||
-rw-r--r-- | ipa-server/xmlrpc-server/ipaxmlrpc.py | 6 |
3 files changed, 19 insertions, 36 deletions
diff --git a/ipa-server/ipaserver/ipaldap.py b/ipa-server/ipaserver/ipaldap.py index 0b2a152e..344e6dc3 100644 --- a/ipa-server/ipaserver/ipaldap.py +++ b/ipa-server/ipaserver/ipaldap.py @@ -39,7 +39,7 @@ from ldap.modlist import modifyModlist from ldap.ldapobject import SimpleLDAPObject -from ipa import ipaerror +from ipa import ipaerror, ipautil class Entry: """This class represents an LDAP Entry object. An LDAP entry consists of a DN @@ -47,7 +47,7 @@ class Entry: values. In python-ldap, entries are returned as a list of 2-tuples. Instance variables: dn - string - the string DN of the entry - data - cidict - case insensitive dict of the attributes and values""" + data - CIDict - case insensitive dict of the attributes and values""" def __init__(self,entrydata): """data is the raw data returned from the python-ldap result method, which is @@ -56,13 +56,13 @@ class Entry: if entrydata: if isinstance(entrydata,tuple): self.dn = entrydata[0] - self.data = ldap.cidict.cidict(entrydata[1]) + self.data = ipautil.CIDict(entrydata[1]) elif isinstance(entrydata,str) or isinstance(entrydata,unicode): self.dn = entrydata - self.data = ldap.cidict.cidict() + self.data = ipautil.CIDict() else: self.dn = '' - self.data = ldap.cidict.cidict() + self.data = ipautil.CIDict() def __nonzero__(self): """This allows us to do tests like if entry: returns false if there is no data, diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py index a0049833..fe48a1ff 100644 --- a/ipa-server/xmlrpc-server/funcs.py +++ b/ipa-server/xmlrpc-server/funcs.py @@ -98,36 +98,19 @@ class IPAServer: return "dn:" + ent.dn def convert_entry(self, ent): - - # Convert to LDIF - entry = str(ent) + entry = dict(ent.data) + entry['dn'] = ent.dn + # For now convert single entry lists to a string for the ui. + # TODO: we need to deal with multi-values better + for key,value in entry.iteritems(): + if isinstance(value,list) or isinstance(value,tuple): + if len(value) == 0: + entry[key] = '' + elif len(value) == 1: + entry[key] = value[0] + return entry - # Strip off any junk - entry = entry.strip() - # Don't need to identify binary fields and this breaks the parser so - # remove double colons - entry = entry.replace('::', ':') - specs = [spec.split(':') for spec in entry.split('\n')] - - # Convert into a dict. We need to handle multi-valued attributes as well - # so we'll convert those into lists. - obj={} - for (k,v) in specs: - k = k.lower() - if obj.get(k) is not None: - if isinstance(obj[k],list): - obj[k].append(v.strip()) - else: - first = obj[k] - obj[k] = [] - obj[k].append(first) - obj[k].append(v.strip()) - else: - obj[k] = v.strip() - - return obj - def __get_entry (self, base, filter, sattrs=None, opts=None): """Get a specific entry. Return as a dict of values. Multi-valued fields are represented as lists. diff --git a/ipa-server/xmlrpc-server/ipaxmlrpc.py b/ipa-server/xmlrpc-server/ipaxmlrpc.py index 9ef1e1b0..16ced2cd 100644 --- a/ipa-server/xmlrpc-server/ipaxmlrpc.py +++ b/ipa-server/xmlrpc-server/ipaxmlrpc.py @@ -35,7 +35,7 @@ from mod_python import apache import ipaserver import funcs -from ipa import ipaerror +from ipa import ipaerror, ipautil import ldap import string @@ -173,14 +173,14 @@ class ModXMLRPCRequestHandler(object): if func is None: raise Fault(1, "Invalid method: %s" % method) - args = list(params) + args = list(ipautil.unwrap_binary_data(params)) for i in range(len(args)): if args[i] == '__NONE__': args[i] = None ret = func(*args) - return ret + return ipautil.wrap_binary_data(ret) def multiCall(self, calls): """Execute a multicall. Execute each method call in the calls list, collecting |