From 6b44cebc097d0cb9d3d22f957d742d9da5ad6afd Mon Sep 17 00:00:00 2001 From: Julian Rother <julianr@fsmpi.rwth-aachen.de> Date: Wed, 17 May 2017 15:33:03 +0200 Subject: [PATCH] Allow custom port for LDAP connections --- config.py.example | 3 ++- db.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config.py.example b/config.py.example index 19ad921..ac539ba 100644 --- a/config.py.example +++ b/config.py.example @@ -23,7 +23,8 @@ SQLITE_INIT_DATA = True #JOBS_API_KEY = 'something random' -#LDAP_HOST = 'ldaps://rumo.fsmpi.rwth-aachen.de' +#LDAP_HOST = 'rumo.fsmpi.rwth-aachen.de' +LDAP_PORT = '636' #ICAL_URL = 'https://user:password@mail.fsmpi.rwth-aachen.de/SOGo/....ics' ERROR_PAGE = 'static/500.html' RWTH_IP_RANGES = ['134.130.0.0/16', '137.226.0.0/16', '134.61.0.0/16', '192.35.229.0/24', '2a00:8a60::/32'] diff --git a/db.py b/db.py index 3965fae..9ca7d77 100644 --- a/db.py +++ b/db.py @@ -152,7 +152,7 @@ if 'LDAP_HOST' in config: def ldapauth(user, password): user = LDAP_USERRE.sub(r'', user.lower()) try: - conn = ldap3.Connection(config['LDAP_HOST'], 'uid=%s,ou=users,dc=fsmpi,dc=rwth-aachen,dc=de'%user, password, auto_bind=True) + conn = ldap3.Connection(ldap3.Server(config['LDAP_HOST'], port=config['LDAP_PORT'], use_ssl=True), 'uid=%s,ou=users,dc=fsmpi,dc=rwth-aachen,dc=de'%user, password, auto_bind=True) groups = [] if conn.search("ou=groups,dc=fsmpi,dc=rwth-aachen,dc=de", "(&(cn=*)(memberUid=%s))"%user, attributes=['cn']): groups = [e['attributes']['cn'][0] for e in conn.response] @@ -163,7 +163,7 @@ if 'LDAP_HOST' in config: def ldapget(user): user = LDAP_USERRE.sub(r'', user.lower()) - conn = ldap3.Connection('ldaps://rumo.fsmpi.rwth-aachen.de', auto_bind=True) + conn = ldap3.Connection(ldap3.Server(config['LDAP_HOST'], port=config['LDAP_PORT'], use_ssl=True), auto_bind=True) conn.search("ou=users,dc=fsmpi,dc=rwth-aachen,dc=de", "(uid=%s)"%user, attributes=ldap3.ALL_ATTRIBUTES) if not conn.response: -- GitLab