diff options
author | Kevin McCarthy <kmccarth@redhat.com> | 2007-08-20 12:10:50 -0700 |
---|---|---|
committer | Kevin McCarthy <kmccarth@redhat.com> | 2007-08-20 12:10:50 -0700 |
commit | cb03961ff1c88179f9667b1dece8288ac55eba44 (patch) | |
tree | 984b49c4316f1069290258c5cee1e543cd738d2f /ipa-python | |
parent | c113d932b1a370cbf868447e32789a4f7c60bea2 (diff) | |
download | freeipa-cb03961ff1c88179f9667b1dece8288ac55eba44.tar.gz freeipa-cb03961ff1c88179f9667b1dece8288ac55eba44.tar.xz freeipa-cb03961ff1c88179f9667b1dece8288ac55eba44.zip |
Convert add_user to take a user instead of a dict.
Diffstat (limited to 'ipa-python')
-rw-r--r-- | ipa-python/ipaclient.py | 29 | ||||
-rw-r--r-- | ipa-python/user.py | 2 |
2 files changed, 17 insertions, 14 deletions
diff --git a/ipa-python/ipaclient.py b/ipa-python/ipaclient.py index 72918999..44c61c6a 100644 --- a/ipa-python/ipaclient.py +++ b/ipa-python/ipaclient.py @@ -61,30 +61,33 @@ class IPAClient: return user.User(result) def add_user(self,user): - """Add a user. user is a cidict() of attribute/value pairs""" + """Add a user. user is a ipa.user object""" realm = config.config.get_realm() # FIXME: This should be dynamic and can include just about anything # Let us add in some missing attributes - if user.get('homedirectory') is None: - user['homedirectory'] ='/home/%s' % user['uid'] - if user.get('gecos') is None: - user['gecos'] = user['uid'] + if user.getValue('homedirectory') is None: + user.setValue('homedirectory', '/home/%s' % user.getValue('uid')) + if user.getValue('gecos') is None: + user.setValue('gecos', user.getValue('uid')) # FIXME: This can be removed once the DS plugin is installed - user['uidnumber'] ='501' + user.setValue('uidnumber', '501') # FIXME: What is the default group for users? - user['gidnumber'] ='501' - user['krbprincipalname'] = "%s@%s" % (user['uid'], realm) - user['cn'] = "%s %s" % (user['givenname'], user['sn']) - if user.get('gn'): - del user['gn'] + user.setValue('gidnumber', '501') + user.setValue('krbprincipalname', "%s@%s" % (user.getValue('uid'), realm)) + user.setValue('cn', "%s %s" % (user.getValue('givenname'), + user.getValue('sn'))) + user_dict = user.toDict() + if user_dict.get('gn'): + del user_dict['gn'] + + del user_dict['dn'] # convert to a regular dict before sending - dict_user = cidict_to_dict(user) - result = self.transport.add_user(dict_user) + result = self.transport.add_user(user_dict) return result def get_all_users(self): diff --git a/ipa-python/user.py b/ipa-python/user.py index 4377dad9..dd0afb57 100644 --- a/ipa-python/user.py +++ b/ipa-python/user.py @@ -25,7 +25,7 @@ class User: data - cidict - case insensitive dict of the attributes and values orig_data - cidict - case insentiive dict of the original attributes and values""" - def __init__(self,entrydata): + def __init__(self,entrydata=None): """data is the raw data returned from the python-ldap result method, which is a search result entry or a reference or None. If creating a new empty entry, data is the string DN.""" |