本文整理匯總了Python中ldap.OPT_OFF屬性的典型用法代碼示例。如果您正苦於以下問題:Python ldap.OPT_OFF屬性的具體用法?Python ldap.OPT_OFF怎麽用?Python ldap.OPT_OFF使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類ldap
的用法示例。
在下文中一共展示了ldap.OPT_OFF屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init_app
# 需要導入模塊: import ldap [as 別名]
# 或者: from ldap import OPT_OFF [as 別名]
def init_app(self, app):
'''
Configures an application. This registers an `after_request` call, and
attaches this `LoginManager` to it as `app.ldap_login_manager`.
'''
self._config = app.config.get('LDAP', {})
app.ldap_login_manager = self
self.config.setdefault('BIND_DN', '')
self.config.setdefault('BIND_AUTH', '')
self.config.setdefault('URI', 'ldap://127.0.0.1')
self.config.setdefault('OPTIONS', {})
# Referrals are disabled by default
self.config['OPTIONS'].setdefault(ldap.OPT_REFERRALS, ldap.OPT_OFF)
if self.config.get('USER_SEARCH') and not isinstance(self.config['USER_SEARCH'], list):
self.config['USER_SEARCH'] = [self.config['USER_SEARCH']]
示例2: _get_conn
# 需要導入模塊: import ldap [as 別名]
# 或者: from ldap import OPT_OFF [as 別名]
def _get_conn(self):
self._log.debug('Setting up LDAP connection')
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
try:
conn = ldap.initialize(self._url)
conn.set_option(ldap.OPT_NETWORK_TIMEOUT, 3)
conn.set_option(ldap.OPT_REFERRALS, ldap.OPT_OFF)
conn.simple_bind_s(self._binddn, self._bindpw)
except (
ldap.SERVER_DOWN,
ldap.NO_SUCH_OBJECT,
ldap.INVALID_CREDENTIALS
) as e:
if hasattr(e, 'message') and 'desc' in e.message:
msg = e.message['desc']
else:
msg = e.args[0]['desc']
self._log.debug('%s (%s)' % (msg, self._url))
return False
self._log.debug('LDAP connection established')
return conn
示例3: ldap_init_conn
# 需要導入模塊: import ldap [as 別名]
# 或者: from ldap import OPT_OFF [as 別名]
def ldap_init_conn(self):
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
conn = ldap.initialize(Setting().get('ldap_uri'))
conn.set_option(ldap.OPT_REFERRALS, ldap.OPT_OFF)
conn.set_option(ldap.OPT_PROTOCOL_VERSION, 3)
conn.set_option(ldap.OPT_X_TLS, ldap.OPT_X_TLS_DEMAND)
conn.set_option(ldap.OPT_X_TLS_DEMAND, True)
conn.set_option(ldap.OPT_DEBUG_LEVEL, 255)
conn.protocol_version = ldap.VERSION3
return conn
示例4: connect
# 需要導入模塊: import ldap [as 別名]
# 或者: from ldap import OPT_OFF [as 別名]
def connect(self):
"""
Establish a connection to the LDAP server.
Raises:
SystemExit
"""
self.conn = ldap.initialize(self.uri)
self.conn.set_option(ldap.OPT_REFERRALS, ldap.OPT_OFF)
try:
self.conn.simple_bind_s(self.ldap_user, self.ldap_pass)
except ldap.SERVER_DOWN as e:
raise SystemExit('Cannot connect to LDAP server: %s' % e)