From a6219ef87a13c3d7e343738fa30a1a2dc0ab3f10 Mon Sep 17 00:00:00 2001 From: Aidaho12 Date: Fri, 9 Nov 2018 14:42:36 +0600 Subject: [PATCH] v3.3 Bufs --- app/create_db.py | 4 +++- app/options.py | 6 ++++-- app/templates/admin.html | 8 ++++++- app/templates/ajax/new_user.html | 36 +++++++++++++++++++------------- app/templates/servers.html | 8 ++++++- 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/app/create_db.py b/app/create_db.py index 7be68309..91204308 100644 --- a/app/create_db.py +++ b/app/create_db.py @@ -277,7 +277,9 @@ def update_db_v_3_3(**kwargs): "INSERT INTO settings (param, value, section, `desc`) values('ldap_port', '389', 'ldap', 'Default port is 389 or 636');", "INSERT INTO settings (param, value, section, `desc`) values('ldap_user', '', 'ldap', 'Login for connect to LDAP server. Enter: user@domain.com');", "INSERT INTO settings (param, value, section, `desc`) values('ldap_password', '', 'ldap', 'Password for connect to LDAP server');", - "INSERT INTO settings (param, value, section, `desc`) values('ldap_base', '', 'ldap', 'Base domain. Example: dc=domain, dc=com');"] + "INSERT INTO settings (param, value, section, `desc`) values('ldap_base', '', 'ldap', 'Base domain. Example: dc=domain, dc=com');", + "INSERT INTO settings (param, value, section, `desc`) values('ldap_domain', '', 'ldap', 'Domain for login, that after @, like user@domain.com, without user@');", + "INSERT INTO settings (param, value, section, `desc`) values('ldap_search_field', 'mail', 'ldap', 'Field where user e-mail saved');"] try: for i in sql: cur.execute(i) diff --git a/app/options.py b/app/options.py index 3c23a62f..0d50b4dc 100644 --- a/app/options.py +++ b/app/options.py @@ -625,6 +625,8 @@ if form.getvalue('get_ldap_email'): user = sql.get_setting('ldap_user') password = sql.get_setting('ldap_password') ldap_base = sql.get_setting('ldap_base') + domain = sql.get_setting('ldap_domain') + ldap_search_field = sql.get_setting('ldap_search_field') l = ldap.initialize("ldap://"+server+':'+port) try: @@ -634,12 +636,12 @@ if form.getvalue('get_ldap_email'): bind = l.simple_bind_s(user, password) criteria = "(&(objectClass=user)(sAMAccountName="+username+"))" - attributes = ['mail'] + attributes = [ldap_search_field] result = l.search_s(ldap_base, ldap.SCOPE_SUBTREE, criteria, attributes) results = [entry for dn, entry in result if isinstance(entry, dict)] try: - print('["'+results[0]['mail'][0].decode("utf-8")+'","'+user.split('@')[1]+'"]') + print('["'+results[0][ldap_search_field][0].decode("utf-8")+'","'+domain+'"]') except: print('error: user not found') finally: diff --git a/app/templates/admin.html b/app/templates/admin.html index ba5e31e3..c63ae71c 100644 --- a/app/templates/admin.html +++ b/app/templates/admin.html @@ -33,7 +33,13 @@ {% for user in users %} - + + {% if user.6 == 1%} + + {% else %} + + {% endif %} + - - + {% if user.6 == 1%} + + {% else %} + + {% endif %} + @@ -21,19 +25,21 @@ {% endfor %} - {% if page != "servers.py" and page != "servers.py#users" %} - - - + {% if page != "servers.py" %} + {% if page != "servers.py#users" %} + + + + {% endif %} {% endif %} diff --git a/app/templates/servers.html b/app/templates/servers.html index 424b9ac4..aaa87c40 100644 --- a/app/templates/servers.html +++ b/app/templates/servers.html @@ -36,7 +36,13 @@ - + + {% if user.6 == 1%} + + {% else %} + + {% endif %} +