mirror of
https://github.com/moepman/bk-dss
synced 2024-11-18 00:19:11 +01:00
Implement adding users.
This commit is contained in:
parent
85d4f414cc
commit
8426e00037
@ -7,5 +7,17 @@ LDAP_BASE = "ou=people,dc=example,dc=com"
|
|||||||
|
|
||||||
ADMINS = [ "cn=admin,ou=people,dc=example,dc=com" ]
|
ADMINS = [ "cn=admin,ou=people,dc=example,dc=com" ]
|
||||||
|
|
||||||
|
CREATE_DN = "cn={user},ou=people,dc=example,dc=com"
|
||||||
|
CREATE_ATTRS = {
|
||||||
|
'objectClass' : ['top', 'inetOrgPerson', 'organizationalPerson', 'person', 'posixAccount'],
|
||||||
|
'cn' : '{user}',
|
||||||
|
'givenName' : '{gn}',
|
||||||
|
'homeDirectory' : '/home/{user}',
|
||||||
|
'loginShell' : '/bin/bash',
|
||||||
|
'sn' : '{sn}',
|
||||||
|
'uid' : '{user}',
|
||||||
|
'uidNumber' : '{uid}'
|
||||||
|
}
|
||||||
|
|
||||||
REDIS_HOST = "127.0.0.1"
|
REDIS_HOST = "127.0.0.1"
|
||||||
REDIS_PSWD = "foobared"
|
REDIS_PSWD = "foobared"
|
||||||
|
19
index.py
19
index.py
@ -78,14 +78,27 @@ def create():
|
|||||||
l = ldap.initialize(app.config.get('LDAP_URI', 'ldaps://127.0.0.1'))
|
l = ldap.initialize(app.config.get('LDAP_URI', 'ldaps://127.0.0.1'))
|
||||||
try:
|
try:
|
||||||
l.simple_bind_s(rdb.hget(session['uuid'], 'user'), rdb.hget(session['uuid'], 'pswd'))
|
l.simple_bind_s(rdb.hget(session['uuid'], 'user'), rdb.hget(session['uuid'], 'pswd'))
|
||||||
# TODO implement
|
d = {
|
||||||
#l.add_s()
|
'user' : form.user.data,
|
||||||
|
'uid' : form.uid.data,
|
||||||
|
'gn' : form.gn.data,
|
||||||
|
'sn' : form.sn.data,
|
||||||
|
}
|
||||||
|
dn = app.config.get('CREATE_DN').format(d)
|
||||||
|
attrs = {}
|
||||||
|
for k,v in app.config.get('CREATE_ATTRS'):
|
||||||
|
if isinstance(v, string):
|
||||||
|
attrs[k] = v.format(d)
|
||||||
|
elif isinstance(v, list):
|
||||||
|
attrs[k] = []
|
||||||
|
for e in v:
|
||||||
|
attrs[k].append(v.format(d))
|
||||||
|
l.add_s(dn, ldap.modlist.addModlist(attrs))
|
||||||
except:
|
except:
|
||||||
l.unbind_s()
|
l.unbind_s()
|
||||||
else:
|
else:
|
||||||
# TODO display success message
|
# TODO display success message
|
||||||
l.unbind_s()
|
l.unbind_s()
|
||||||
pass
|
|
||||||
|
|
||||||
return render_template('create.html', form=form, nav=buildNav())
|
return render_template('create.html', form=form, nav=buildNav())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user