def connect(self):
        'initialize ldap connection and set options'
        log.debug("Connecting to ldap server %s" % self.config['URI'])
        self.conn = ldap.initialize(self.config['URI'])

        for opt, value in self.config.get('OPTIONS', {}).items():
            if isinstance(opt, str):
                opt = getattr(ldap, opt)

            try:
                if isinstance(value, str):
                    value = getattr(ldap, value)
            except AttributeError:
                pass
            self.conn.set_option(opt, value)

        if self.config.get('START_TLS'):
            log.debug("Starting TLS")
            self.conn.start_tls_s()
dataset/ETHPy150Open ContinuumIO/flask-ldap-login/flask_ldap_login/__init__.py/LDAPLoginManager.connect/original