mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-28 09:06:44 -06:00
More work on making user-add use Backend.ldap
This commit is contained in:
parent
1480224724
commit
9788800aa4
@ -25,10 +25,10 @@ This wraps the python-ldap bindings.
|
|||||||
|
|
||||||
import ldap as _ldap
|
import ldap as _ldap
|
||||||
from ipalib import api
|
from ipalib import api
|
||||||
from ipalib.backend import Backend
|
from ipalib.crud import CrudBackend
|
||||||
|
|
||||||
|
|
||||||
class ldap(Backend):
|
class ldap(CrudBackend):
|
||||||
"""
|
"""
|
||||||
LDAP backend plugin.
|
LDAP backend plugin.
|
||||||
"""
|
"""
|
||||||
@ -45,4 +45,7 @@ class ldap(Backend):
|
|||||||
self.api.env.basedn,
|
self.api.env.basedn,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def create(self, **kw):
|
||||||
|
return kw
|
||||||
|
|
||||||
api.register(ldap)
|
api.register(ldap)
|
||||||
|
@ -55,20 +55,36 @@ class user(frontend.Object):
|
|||||||
User object.
|
User object.
|
||||||
"""
|
"""
|
||||||
takes_params = (
|
takes_params = (
|
||||||
Param('givenname', cli_name='firstname'),
|
Param('givenname',
|
||||||
Param('sn', cli_name='lastname'),
|
cli_name='first',
|
||||||
|
doc='User first name',
|
||||||
|
),
|
||||||
|
Param('sn',
|
||||||
|
cli_name='last',
|
||||||
|
doc='User last name',
|
||||||
|
),
|
||||||
Param('uid',
|
Param('uid',
|
||||||
cli_name='user',
|
cli_name='user',
|
||||||
primary_key=True,
|
primary_key=True,
|
||||||
default_from=lambda givenname, sn: givenname[0] + sn,
|
default_from=lambda givenname, sn: givenname[0] + sn,
|
||||||
normalize=lambda value: value.lower(),
|
normalize=lambda value: value.lower(),
|
||||||
),
|
),
|
||||||
Param('krbprincipalname',
|
Param('gecos',
|
||||||
default_from=lambda uid: '%s@EXAMPLE.COM' % uid,
|
doc='GECOS field',
|
||||||
|
default_from=lambda uid: uid,
|
||||||
),
|
),
|
||||||
Param('homedirectory',
|
Param('homedirectory',
|
||||||
|
cli_name='home',
|
||||||
|
doc='Path of user home directory',
|
||||||
default_from=lambda uid: '/home/%s' % uid,
|
default_from=lambda uid: '/home/%s' % uid,
|
||||||
)
|
),
|
||||||
|
Param('shell',
|
||||||
|
default=u'/bin/sh',
|
||||||
|
doc='Login shell',
|
||||||
|
),
|
||||||
|
Param('krbprincipalname?', cli_name='principal',
|
||||||
|
default_from=lambda uid: '%s@EXAMPLE.COM' % uid,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
api.register(user)
|
api.register(user)
|
||||||
|
|
||||||
@ -90,21 +106,11 @@ class user_add(crud.Add):
|
|||||||
"""
|
"""
|
||||||
assert 'uid' not in kw
|
assert 'uid' not in kw
|
||||||
assert 'dn' not in kw
|
assert 'dn' not in kw
|
||||||
|
ldap = self.api.Backend.ldap
|
||||||
kw['uid'] = uid
|
kw['uid'] = uid
|
||||||
kw['dn'] = self.api.Backend.ldap.get_user_dn(uid)
|
kw['dn'] = ldap.get_user_dn(uid)
|
||||||
|
return ldap.create(**kw)
|
||||||
|
|
||||||
return kw
|
|
||||||
|
|
||||||
# FIXME: ug, really?
|
|
||||||
if not kw.get('container'):
|
|
||||||
user_container = servercore.DefaultUserContainer
|
|
||||||
else:
|
|
||||||
user_container = kw['container']
|
|
||||||
del kw['container']
|
|
||||||
|
|
||||||
user = kw
|
|
||||||
|
|
||||||
user['uid'] = args[0]
|
|
||||||
|
|
||||||
if servercore.user_exists(user['uid']):
|
if servercore.user_exists(user['uid']):
|
||||||
raise errors.Duplicate("user already exists")
|
raise errors.Duplicate("user already exists")
|
||||||
|
Loading…
Reference in New Issue
Block a user