This commit is contained in:
aitzol 2022-04-29 10:16:13 +02:00
parent cee47b5ace
commit ebd94ac0c1

5
app.py
View File

@ -30,7 +30,6 @@ from ldap3.core.exceptions import LDAPBindError, LDAPConstraintViolationResult,
LDAPSocketOpenError, LDAPExceptionError LDAPSocketOpenError, LDAPExceptionError
import logging import logging
from os import getenv, environ, path from os import getenv, environ, path
#import re
from libs import flist, slist from libs import flist, slist
from libs.localization import * from libs.localization import *
from libs.helper import * from libs.helper import *
@ -506,7 +505,7 @@ def register(conf, username, firstname, surname, password, email, isFake):
directory = 'home/user/'+to_ascii(username) directory = 'home/user/'+to_ascii(username)
OBJECT_CLASS = ['top', 'inetOrgPerson', 'posixAccount', 'accountsManagement'] OBJECT_CLASS = ['top', 'inetOrgPerson', 'posixAccount', 'accountsManagement']
attributes = {'gidNumber': '501', 'uidNumber': uidNumber, 'homeDirectory': directory, 'givenName': firstname, 'sn': surname, 'uid' : username, 'mail': email, 'active': False, 'fakeCn': isFake} attributes = {'gidNumber': '501', 'uidNumber': uidNumber, 'homeDirectory': directory, 'givenName': firstname, 'sn': surname, 'uid' : username, 'mail': email, 'active': False, 'fakeCn': isFake}
new_user_dn = "cn="+firstname+" "+ surname+",cn=users,"+conf['base'] new_user_dn = "cn="+firstname+" "+surname+" - "+username+",cn=users,"+conf['base']
c.add(dn=new_user_dn,object_class=OBJECT_CLASS, attributes=attributes) c.add(dn=new_user_dn,object_class=OBJECT_CLASS, attributes=attributes)
#create/change user password #create/change user password
c.extend.standard.modify_password(new_user_dn, '', password) c.extend.standard.modify_password(new_user_dn, '', password)
@ -562,7 +561,7 @@ def update_fullname(conf, username, firstname, surname):
user_dn = find_user_dn(conf, c, username) user_dn = find_user_dn(conf, c, username)
c.modify(user_dn, {'givenName': [( MODIFY_REPLACE, firstname )], 'sn': [( MODIFY_REPLACE, surname )]}) c.modify(user_dn, {'givenName': [( MODIFY_REPLACE, firstname )], 'sn': [( MODIFY_REPLACE, surname )]})
new_cn = "cn="+firstname+" "+ surname new_cn = "cn="+firstname+" "+ surname+" - "+ username
c.modify_dn(user_dn, new_cn) c.modify_dn(user_dn, new_cn)
new_user_dn = new_cn+",cn=users,"+conf['base'] new_user_dn = new_cn+",cn=users,"+conf['base']