diff --git a/web/config.py b/web/config.py index 08b4a84fc..0848f2325 100644 --- a/web/config.py +++ b/web/config.py @@ -645,6 +645,15 @@ LDAP_ANONYMOUS_BIND = False # OpenLDAP example: CN=Users,dc=example,dc=com LDAP_BASE_DN = '' +# Configure the bind format string +# Default: LDAP_BIND_FORMAT=" +# {LDAP_USERNAME_ATTRIBUTE}={LDAP_USERNAME},{LDAP_BASE_DN}" +# The current available options are: +# LDAP_USERNAME_ATTRIBUTE, LDAP_USERNAME, LDAP_BASE_DN +# Example: LDAP_BIND_FORMAT="myldapuser@sales.example.com" +# LDAP_BIND_FORMAT="NET\\myldapuser" +LDAP_BIND_FORMAT = '{LDAP_USERNAME_ATTRIBUTE}={LDAP_USERNAME},{LDAP_BASE_DN}' + ########################################################################## # Search ldap for further authentication (REQUIRED) diff --git a/web/pgadmin/authenticate/ldap.py b/web/pgadmin/authenticate/ldap.py index 8c8825f26..10c9d432a 100644 --- a/web/pgadmin/authenticate/ldap.py +++ b/web/pgadmin/authenticate/ldap.py @@ -65,10 +65,13 @@ class LDAPAuthentication(BaseAuthentication): # username and password if not self.bind_user and not self.bind_pass and\ self.anonymous_bind is False: - user_dn = "{0}={1},{2}".format(config.LDAP_USERNAME_ATTRIBUTE, - self.username, - config.LDAP_BASE_DN - ) + + user_dn = config.LDAP_BIND_FORMAT\ + .format( + LDAP_USERNAME=self.username, + LDAP_BASE_DN=config.LDAP_BASE_DN, + LDAP_USERNAME_ATTRIBUTE=config.LDAP_USERNAME_ATTRIBUTE + ) self.bind_user = user_dn self.bind_pass = self.password