mirror of
https://github.com/getredash/redash.git
synced 2025-12-25 01:03:20 -05:00
Support LDAP servers where one doesn't first have to bind to the LDAP server with a username/password (#3002)
* Support LDAP servers where one doesn't first have to bind to the LDAP server with a username/password * Address code climate things
This commit is contained in:
@@ -62,7 +62,16 @@ def login(org_slug=None):
|
||||
|
||||
def auth_ldap_user(username, password):
|
||||
server = Server(settings.LDAP_HOST_URL, use_ssl=settings.LDAP_SSL)
|
||||
conn = Connection(server, settings.LDAP_BIND_DN, password=settings.LDAP_BIND_DN_PASSWORD, authentication=settings.LDAP_AUTH_METHOD, auto_bind=True)
|
||||
if settings.LDAP_BIND_DN is not None:
|
||||
conn = Connection(
|
||||
server,
|
||||
settings.LDAP_BIND_DN,
|
||||
password=settings.LDAP_BIND_DN_PASSWORD,
|
||||
authentication=settings.LDAP_AUTH_METHOD,
|
||||
auto_bind=True
|
||||
)
|
||||
else:
|
||||
conn = Connection(server, auto_bind=True)
|
||||
|
||||
conn.search(settings.LDAP_SEARCH_DN, settings.LDAP_SEARCH_TEMPLATE % {"username": username}, attributes=[settings.LDAP_DISPLAY_NAME_KEY, settings.LDAP_EMAIL_KEY])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user