Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple LDAP servers #184

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions ldapauthenticator/ldapauthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class LDAPAuthenticator(Authenticator):
server_address = Unicode(
server_address = List(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change, if you use traitlets.Union you should be able to maintain backwards compatibility.

config=True,
help="""
Address of the LDAP server to contact.
Expand Down Expand Up @@ -305,14 +305,15 @@ def resolve_username(self, username_supplied_by_user):
return (user_dn, response[0]["dn"])

def get_connection(self, userdn, password):
server = ldap3.Server(
self.server_address, port=self.server_port, use_ssl=self.use_ssl
)
server_pool = ldap3.ServerPool(self.server_address,
ldap3.ROUND_ROBIN,
active=True,
exhaust=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change self.server_port is ignored

auto_bind = (
ldap3.AUTO_BIND_NO_TLS if self.use_ssl else ldap3.AUTO_BIND_TLS_BEFORE_BIND
self.use_ssl and ldap3.AUTO_BIND_TLS_BEFORE_BIND or ldap3.AUTO_BIND_NO_TLS
)
conn = ldap3.Connection(
server, user=userdn, password=password, auto_bind=auto_bind
server_pool, user=userdn, password=password, auto_bind=auto_bind
)
return conn

Expand Down