Skip to content

Commit

Permalink
Introduce LDAP configuration parameter LDAP_IGNORE_MALFORMED_SCHEMA t…
Browse files Browse the repository at this point in the history
…o ignore fetching schema from the LDAP server. pgadmin-org#7062
  • Loading branch information
khushboovashi authored Jan 1, 2024
1 parent fd8af40 commit 3fa4e82
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/en_US/ldap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ There are 3 ways to configure LDAP:
"LDAP_KEY_FILE","Specifies the path to the server private key file. This parameter
is applicable only if you are using *ldaps* as connection protocol or you have
set *LDAP_USE_STARTTLS* parameter to *True*."
"LDAP_IGNORE_MALFORMED_SCHEMA", "Some flaky LDAP servers returns malformed schema.
If this parameter set to *True*, no exception will be raised and schema is thrown away
but authentication will be done. This parameter should remain False, as recommended."
"**Bind as pgAdmin user**"
"LDAP_BASE_DN","Specifies the base DN from where a server will start the search
for users. For example, an LDAP search for any user will be performed by the server
Expand Down
7 changes: 7 additions & 0 deletions web/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,13 @@
LDAP_CERT_FILE = ''
LDAP_KEY_FILE = ''

##########################################################################

# Some flaky LDAP servers returns malformed schema. If True, no exception
# will be raised and schema is thrown away but authentication will be done.
# This parameter should remain False, as recommended.
LDAP_IGNORE_MALFORMED_SCHEMA = False

##########################################################################
# Kerberos Configuration
##########################################################################
Expand Down
6 changes: 5 additions & 1 deletion web/pgadmin/authenticate/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import ssl
import config
from ldap3 import Connection, Server, Tls, ALL, ALL_ATTRIBUTES, ANONYMOUS,\
SIMPLE, AUTO_BIND_TLS_BEFORE_BIND, AUTO_BIND_NO_TLS
SIMPLE, AUTO_BIND_TLS_BEFORE_BIND, AUTO_BIND_NO_TLS, set_config_parameter
from ldap3.core.exceptions import LDAPSocketOpenError, LDAPBindError,\
LDAPInvalidScopeError, LDAPAttributeError, LDAPInvalidFilterError,\
LDAPStartTLSError, LDAPSSLConfigurationError
Expand All @@ -33,6 +33,10 @@
ERROR_CONNECTING_LDAP_SERVER = gettext(
"Error connecting to the LDAP server: {}\n")

if config.LDAP_IGNORE_MALFORMED_SCHEMA:
set_config_parameter('IGNORE_MALFORMED_SCHEMA',
config.LDAP_IGNORE_MALFORMED_SCHEMA)


class LDAPAuthentication(BaseAuthentication):
"""Ldap Authentication Class"""
Expand Down

0 comments on commit 3fa4e82

Please sign in to comment.