summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kmccarth@redhat.com>2007-08-17 14:27:54 -0700
committerKevin McCarthy <kmccarth@redhat.com>2007-08-17 14:27:54 -0700
commita0e2fa00f1005bf7d5853c83ff0f567663352e92 (patch)
tree9a000cf4db2e32d0217e6a845e086ae8d726a4aa
parent48bb474e6848f02de2b77a7abf6aed13857267ee (diff)
downloadfreeipa-a0e2fa00f1005bf7d5853c83ff0f567663352e92.tar.gz
freeipa-a0e2fa00f1005bf7d5853c83ff0f567663352e92.tar.xz
freeipa-a0e2fa00f1005bf7d5853c83ff0f567663352e92.zip
Manual merge changes in for the cidict/ipaclient add_user()
-rw-r--r--ipa-admintools/ipa-adduser3
-rw-r--r--ipa-python/ipaclient.py14
-rw-r--r--ipa-server/ipaserver/ipaldap.py2
-rw-r--r--ipa-server/xmlrpc-server/funcs.py19
4 files changed, 33 insertions, 5 deletions
diff --git a/ipa-admintools/ipa-adduser b/ipa-admintools/ipa-adduser
index f28c5dc26..f31a335f0 100644
--- a/ipa-admintools/ipa-adduser
+++ b/ipa-admintools/ipa-adduser
@@ -26,6 +26,7 @@ import ipa.config
import xmlrpclib
import kerberos
+import ldap
def usage():
print "ipa-adduser [-c|--gecos STRING] [-d|--directory STRING] [-f|--firstname STRING] [-l|--lastname STRING] user"
@@ -55,7 +56,7 @@ def parse_options():
return options, args
def main():
- user={}
+ user=ldap.cidict.cidict()
options, args = parse_options()
if len(args) != 2:
diff --git a/ipa-python/ipaclient.py b/ipa-python/ipaclient.py
index 28e560018..2d4e727ae 100644
--- a/ipa-python/ipaclient.py
+++ b/ipa-python/ipaclient.py
@@ -29,6 +29,14 @@ import user
import ipa
import config
+def cidict_to_dict(cid):
+ """Convert a cidict to a standard dict for sending across the wire"""
+ newdict = {}
+ kindex = cid.keys()
+ for dkey in kindex:
+ newdict[dkey] = cid[dkey]
+ return newdict
+
class IPAClient:
def __init__(self,local=None):
@@ -53,7 +61,7 @@ class IPAClient:
return user.User(result)
def add_user(self,user):
- """Add a user. user is a dict of attribute/value pairs"""
+ """Add a user. user is a cidict() of attribute/value pairs"""
realm = config.config.get_realm()
@@ -74,7 +82,9 @@ class IPAClient:
if user.get('gn'):
del user['gn']
- result = self.transport.add_user(user)
+ # convert to a regular dict before sending
+ dict_user = cidict_to_dict(user)
+ result = self.transport.add_user(dict_user)
return result
def get_all_users(self):
diff --git a/ipa-server/ipaserver/ipaldap.py b/ipa-server/ipaserver/ipaldap.py
index 936dd662b..a0f1cab4a 100644
--- a/ipa-server/ipaserver/ipaldap.py
+++ b/ipa-server/ipaserver/ipaldap.py
@@ -63,7 +63,7 @@ class Entry:
if isinstance(entrydata,tuple):
self.dn = entrydata[0]
self.data = ldap.cidict.cidict(entrydata[1])
- elif isinstance(entrydata,str):
+ elif isinstance(entrydata,str) or isinstance(entrydata,unicode):
self.dn = entrydata
self.data = ldap.cidict.cidict()
else:
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py
index df8bceaa7..22f52dae3 100644
--- a/ipa-server/xmlrpc-server/funcs.py
+++ b/ipa-server/xmlrpc-server/funcs.py
@@ -171,14 +171,31 @@ class IPAServer:
return self.convert_entry(ent)
- def add_user (self, user, user_container="ou=users,ou=default",opts=None):
+ def add_user (self, args, user_container="ou=users,ou=default",opts=None):
"""Add a user in LDAP. Takes as input a dict where the key is the
attribute name and the value is either a string or in the case
of a multi-valued field a list of values. user_container sets
where in the tree the user is placed."""
global _LDAPPool
+
+ # The XML-RPC server marshals the arguments into one variable
+ # while the direct caller has them separate. So do a little
+ # bit of gymnastics to figure things out. There has to be a
+ # better way, so FIXME
+ if isinstance(args,tuple):
+ opts = user_container
+ if len(args) == 2:
+ user = args[0]
+ user_container = args[1]
+ else:
+ user = args
+ user_container = "ou=users,ou=default"
+ else:
+ user = args
+
if (isinstance(user, tuple)):
user = user[0]
+
dn="uid=%s,%s,%s" % (user['uid'], user_container,self.basedn)
entry = ipaserver.ipaldap.Entry(str(dn))