MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / _configure_server

Method _configure_server

web/pgadmin/authenticate/ldap.py:233–266  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

231 return True, tls
232
233 def _configure_server(self):
234 # Parse the server URI
235 uri = getattr(config, 'LDAP_SERVER_URI', None)
236
237 if uri:
238 uri = urlparse(uri)
239
240 # Create the TLS configuration object if required
241 tls = None
242
243 if isinstance(uri, str):
244 return False, gettext(
245 "LDAP configuration error: Set the proper LDAP URI.")
246
247 if uri.scheme == 'ldaps' or config.LDAP_USE_STARTTLS:
248 status, tls = self.__configure_tls()
249 if not status:
250 return status, tls
251
252 if uri.scheme != 'ldaps' and config.LDAP_USE_STARTTLS:
253 self.start_tls = True
254
255 try:
256 # Create the server object
257 server = Server(uri.hostname,
258 port=uri.port,
259 use_ssl=(uri.scheme == 'ldaps'),
260 get_info=ALL,
261 tls=tls,
262 connect_timeout=config.LDAP_CONNECTION_TIMEOUT)
263 except ValueError as e:
264 return False, "LDAP configuration error: {}.".format(e)
265
266 return True, server
267
268 def search_ldap_user(self):
269 """Get a list of users from the LDAP server based on config

Callers 1

connectMethod · 0.95

Calls 3

__configure_tlsMethod · 0.95
gettextFunction · 0.85
ServerClass · 0.85

Tested by

no test coverage detected