Move add user logic to the server side

This commit is contained in:
rcritten@redhat.com
2007-08-23 11:57:25 -04:00
parent 8879ee173e
commit 240a99b6f3
2 changed files with 29 additions and 17 deletions

View File

@@ -71,25 +71,9 @@ class IPAClient:
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.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.setValue('uidnumber', '501')
# FIXME: What is the default group for users?
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']
# dn is set on the server-side
del user_dict['dn']
# convert to a regular dict before sending

View File

@@ -172,6 +172,34 @@ class IPAServer:
dn="uid=%s,%s,%s" % (user['uid'], user_container,self.basedn)
entry = ipaserver.ipaldap.Entry(dn)
# 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.get('uid')
if not user.get('gecos') is None:
user['gecos'] = user['uid']
# FIXME: This can be removed once the DS plugin is installed
user['uidnumber'] = '501'
# FIXME: What is the default group for users?
user['gidnumber'] = '501'
realm = ipa.config.config.get_realm()
user['krbprincipalname'] = "%s@%s" % (user.get('uid'), realm)
# FIXME. This is a hack so we can request separate First and Last
# name in the GUI.
if user.get('cn') is None:
user['cn'] = "%s %s" % (user.get('givenname'),
user.get('sn'))
if user.get('gn'):
del user['gn']
if user.get('givenname'):
del user['givenname']
# some required objectclasses
entry.setValues('objectClass', 'top', 'posixAccount', 'shadowAccount', 'account', 'person', 'inetOrgPerson', 'organizationalPerson', 'krbPrincipalAux', 'krbTicketPolicyAux')