diff --git a/config.py.example b/config.py.example index 19ad921d65699e378145762d715c06ed37be4398..ac539ba20bc9946bb6216398aa06e7c7e79d3223 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 3965fae7dda6d8604551b11cfa309f9a16d046ca..9ca7d772b7d14c4cbf8deecea76b975a5d497c54 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: