def _checkpw(self, user, password): dn = str(DN(('uid', user), api.env.container_user, api.env.basedn)) conn = ldap_initialize(api.env.ldap_uri) try: conn.simple_bind_s(dn, password) finally: conn.unbind_s()
def __init__(self): self.connection = ldap_initialize( 'ldap://{host}'.format(host=ipalib.api.env.host) ) auth = ldap.sasl.gssapi('') self.connection.sasl_interactive_bind_s('', auth)
def setup_class(cls): super(TestDeniedBindWithExpiredPrincipal, cls).setup_class() cls.connection = ldap_initialize( 'ldap://{host}'.format(host=api.env.host) ) cls.connection.start_tls_s()
def connect(self): conn = ldap_initialize(self.uri) if self.auth_type == 'EXTERNAL': auth_tokens = ldap.sasl.external(None) elif self.auth_type == 'GSSAPI': auth_tokens = ldap.sasl.sasl({}, 'GSSAPI') else: raise ValueError( 'Invalid authentication type: %s' % self.auth_type) conn.sasl_interactive_bind_s('', auth_tokens) return conn
def connect(self): conn = ldap_initialize(self.uri) if self.auth_type == 'EXTERNAL': auth_tokens = ldap.sasl.external(None) elif self.auth_type == 'GSSAPI': auth_tokens = ldap.sasl.sasl({}, 'GSSAPI') else: raise ValueError('Invalid authentication type: %s' % self.auth_type) conn.sasl_interactive_bind_s('', auth_tokens) return conn
def _connect(self): if (self._start_tls and self.protocol == 'ldap' and self._no_certificate_check): with self.error_handler(): conn = ipaldap.ldap_initialize(self.ldap_uri, cacertfile=self._cacert) conn.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER) conn.set_option(ldap.OPT_X_TLS_NEWCTX, 0) conn.start_tls_s() return conn else: return super(LDAPClientWithoutCertCheck, self)._connect()
def populate_schema_cache(api=api): """populate schema cache in parent process LDAP server schema is available for anonymous binds. """ conn = ipaldap.ldap_initialize(api.env.ldap_uri) try: ipaldap.schema_cache.get_schema(api.env.ldap_uri, conn) except Exception as e: logger.error("Failed to pre-populate LDAP schema cache: %s", e) finally: try: conn.unbind_s() except AttributeError: # SimpleLDAPObject has no attribute '_l' pass
def bind_with_expired_principal_setup(self, request, xmlrpc_setup): cls = request.cls cls.connection = ldap_initialize( 'ldap://{host}'.format(host=api.env.host)) cls.connection.start_tls_s()