flask_ldap3_login/__init__.py
def _make_connection(self, bind_user=None, bind_password=None,
                         contextualise=True, **kwargs):
        """
        Make a connection.

        Args:
            bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
                used, otherwise authentication specified with
                config['LDAP_BIND_AUTHENTICATION_TYPE'] is used.
            bind_password (str): Password to bind to the directory with
            contextualise (bool): If true (default), will add this connection to the
                appcontext so it can be unbound upon app_teardown.

        Returns:
            ldap3.Connection: An unbound ldap3.Connection. You should handle exceptions
                upon bind if you use this internal method.
        """

        authentication = ldap3.ANONYMOUS
        if bind_user:
            authentication = getattr(ldap3, self.config.get(
                'LDAP_BIND_AUTHENTICATION_TYPE'))

        log.debug("Opening connection with bind user '{0}'".format(
            bind_user or 'Anonymous'))
        connection = ldap3.Connection(
            server=self._server_pool,
            read_only=self.config.get('LDAP_READONLY'),
            user=bind_user,
            password=bind_password,
            client_strategy=ldap3.SYNC,
            authentication=authentication,
            check_names=self.config['LDAP_CHECK_NAMES'],
            raise_exceptions=True,
            **kwargs
        )

        if contextualise:
            self._contextualise_connection(connection)
        return connection
def _make_connection(self, bind_user=None, bind_password=None,
                         contextualise=True, **kwargs):
        authentication = ldap3.ANONYMOUS
        if bind_user:
            authentication = getattr(ldap3, self.config.get(
                'LDAP_BIND_AUTHENTICATION_TYPE'))

        log.debug("Opening connection with bind user '{0}'".format(
            bind_user or 'Anonymous'))
        connection = ldap3.Connection(
            server=self._server_pool,
            read_only=self.config.get('LDAP_READONLY'),
            user=bind_user,
            password=bind_password,
            client_strategy=ldap3.SYNC,
            authentication=authentication,
            check_names=self.config['LDAP_CHECK_NAMES'],
            raise_exceptions=True,
            **kwargs
        )

        if contextualise:
            self._contextualise_connection(connection)
        return connection
def _make_connection ( self , bind_user = None , bind_password = None , contextualise = True , * * kwargs ) : authentication = ldap3 . ANONYMOUS if bind_user : authentication = getattr ( ldap3 , self . config . get ( 'LDAP_BIND_AUTHENTICATION_TYPE' ) ) log . debug ( "Opening connection with bind user '{0}'" . format ( bind_user or 'Anonymous' ) ) connection = ldap3 . Connection ( server = self . _server_pool , read_only = self . config . get ( 'LDAP_READONLY' ) , user = bind_user , password = bind_password , client_strategy = ldap3 . SYNC , authentication = authentication , check_names = self . config [ 'LDAP_CHECK_NAMES' ] , raise_exceptions = True , * * kwargs ) if contextualise : self . _contextualise_connection ( connection ) return connection
Make a connection.

        Args:
            bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
                used, otherwise authentication specified with
                config['LDAP_BIND_AUTHENTICATION_TYPE'] is used.
            bind_password (str): Password to bind to the directory with
            contextualise (bool): If true (default), will add this connection to the
                appcontext so it can be unbound upon app_teardown.

        Returns:
            ldap3.Connection: An unbound ldap3.Connection. You should handle exceptions
                upon bind if you use this internal method.
Make a connection .