def __init__(self, name, username, password, authoritative_source, auth_options=None):

        if auth_options is None:
            auth_options = {}

        BaseAuth.__init__(self, username, password, authoritative_source, name, auth_options)
        base_auth_backend = 'auth.backends.' + self.auth_backend
        self._ldap_uri = self._cfg.get(base_auth_backend, 'uri')
        self._ldap_basedn = self._cfg.get(base_auth_backend, 'basedn')
        self._ldap_binddn_fmt = self._cfg.get(base_auth_backend, 'binddn_fmt')
        self._ldap_search = self._cfg.get(base_auth_backend, 'search')
        self._ldap_tls = False

        if self._cfg.has_option(base_auth_backend, 'tls'):
            self._ldap_tls = self._cfg.getboolean(base_auth_backend, 'tls')

        self._ldap_ro_group = None
        self._ldap_rw_group = None
        if self._cfg.has_option(base_auth_backend, 'ro_group'):
            self._ldap_ro_group = self._cfg.get(base_auth_backend, 'ro_group')
        if self._cfg.has_option(base_auth_backend, 'rw_group'):
            self._ldap_rw_group = self._cfg.get(base_auth_backend, 'rw_group')

        self._logger.debug('Creating LdapAuth instance')

        if not ldap:
            self._logger.error('Unable to load Python ldap module, please verify it is installed')
            raise AuthError('Unable to authenticate')

        self._logger.debug('LDAP URI: ' + self._ldap_uri)
        self._ldap_conn = ldap.initialize(self._ldap_uri)

        # Shall we use a separate connection for search?
        if self._cfg.has_option(base_auth_backend, 'search_binddn'):
            self._ldap_search_binddn = self._cfg.get(base_auth_backend, 'search_binddn')
            self._ldap_search_password = self._cfg.get(base_auth_backend, 'search_password')
            self._ldap_search_conn = ldap.initialize(self._ldap_uri)

        if self._ldap_tls:
            try:
                self._ldap_conn.start_tls_s()
                if self._ldap_search_conn is not None:
                    self._ldap_search_conn.start_tls_s()
            except (ldap.CONNECT_ERROR, ldap.SERVER_DOWN) as exc:
                self._logger.error('Attempted to start TLS with ldap server but failed.')
                self._logger.exception(exc)
                raise AuthError('Unable to establish secure connection to ldap server')
Constructor.
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/authlib.py/LdapAuth.__init__