本文整理匯總了Python中freenasUI.common.freenasldap.FreeNAS_LDAP.open方法的典型用法代碼示例。如果您正苦於以下問題:Python FreeNAS_LDAP.open方法的具體用法?Python FreeNAS_LDAP.open怎麽用?Python FreeNAS_LDAP.open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類freenasUI.common.freenasldap.FreeNAS_LDAP
的用法示例。
在下文中一共展示了FreeNAS_LDAP.open方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: LDAP
# 需要導入模塊: from freenasUI.common.freenasldap import FreeNAS_LDAP [as 別名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_LDAP import open [as 別名]
class LDAP(TestObject):
def __init__(self, handler=None):
super(self.__class__, self).__init__(handler)
self._name = "LDAP"
self.freenas_ldap = FreeNAS_LDAP(flags=FLAGS_DBINIT)
def Enabled(self):
return ldap_enabled()
def Test(self):
try:
self.freenas_ldap.open()
if self.freenas_ldap._handle.whoami_s():
return self._handler.Pass("LDAP")
else:
return self._handler.Fail("LDAP", "Unable to query the server.")
except LDAPError as e:
# LDAPError is dumb, it returns a list with one element for goodness knows what reason
e = e[0]
error = ""
if 'desc' in e:
error = e['desc']
if 'info' in e:
error = "{0}, {1}".format(error, e['info'])
else:
# LDAPError may have desc and info or just info so making a case that handles just info
if 'info' in e:
error = e['info']
else:
error = str(e)
return self._handler.Fail("LDAP", error)
except Exception as e:
return self._handler.Fail("LDAP", str(e))
示例2: ldap_status
# 需要導入模塊: from freenasUI.common.freenasldap import FreeNAS_LDAP [as 別名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_LDAP import open [as 別名]
def ldap_status(self):
ret = False
try:
f = FreeNAS_LDAP(flags=FLAGS_DBINIT)
f.open()
if f.isOpen():
ret = True
f.close()
except:
pass
return ret
示例3: LDAP
# 需要導入模塊: from freenasUI.common.freenasldap import FreeNAS_LDAP [as 別名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_LDAP import open [as 別名]
class LDAP(TestObject):
def __init__(self, handler=None):
super(self.__class__, self).__init__(handler)
self._name = "LDAP"
self.freenas_ldap = FreeNAS_LDAP(flags=FLAGS_DBINIT)
def Enabled(self):
return ldap_enabled()
def Test(self):
try:
self.freenas_ldap.open()
if self.freenas_ldap._handle.whoami_s():
return self._handler.Pass("LDAP")
else:
return self._handler.Fail("LDAP", "Unable to query the server.")
except Exception as e:
return self._handler.Fail("LDAP", str(e))
示例4: LDAP
# 需要導入模塊: from freenasUI.common.freenasldap import FreeNAS_LDAP [as 別名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_LDAP import open [as 別名]
class LDAP(TestObject):
def __init__(self, handler=None):
super(self.__class__, self).__init__(handler)
self._name = "LDAP"
self.freenas_ldap = FreeNAS_LDAP(flags=FLAGS_DBINIT)
def Enabled(self):
return ldap_enabled()
def Test(self):
try:
self.freenas_ldap.open()
if self.freenas_ldap._handle.whoami_s():
return self._handler.Pass("LDAP")
else:
return self._handler.Fail("LDAP", "Unable to query the server.")
except LDAPError as e:
# LDAPError is dumb, it returns a list with one element for goodness knows what reason
e = e[0]
error = []
desc = e.get('desc')
info = e.get('info')
if desc:
error.append(desc)
if info:
error.append(info)
if error:
error = ', '.join(error)
else:
error = str(e)
return self._handler.Fail("LDAP", error)
except Exception as e:
return self._handler.Fail("LDAP", str(e))