本文整理汇总了Python中freenasUI.common.freenasldap.FreeNAS_ActiveDirectory.connected方法的典型用法代码示例。如果您正苦于以下问题:Python FreeNAS_ActiveDirectory.connected方法的具体用法?Python FreeNAS_ActiveDirectory.connected怎么用?Python FreeNAS_ActiveDirectory.connected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freenasUI.common.freenasldap.FreeNAS_ActiveDirectory
的用法示例。
在下文中一共展示了FreeNAS_ActiveDirectory.connected方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ActiveDirectory
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import connected [as 别名]
class ActiveDirectory(TestObject):
def __init__(self, handler=None):
super(self.__class__, self).__init__(handler)
self._name = "ActiveDirectory"
self.freenas_ad = None
def Enabled(self):
return activedirectory_enabled()
def Test(self):
try:
self.freenas_ad = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
if self.freenas_ad.connected():
return self._handler.Pass("ActiveDirectory")
else:
return self._handler.Fail("ActiveDirectory", "Unable to login to the Domain Controller.")
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("ActiveDirectory", error)
except Exception as e:
return self._handler.Fail("ActiveDirectory", str(e))
示例2: ActiveDirectory
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import connected [as 别名]
class ActiveDirectory(TestObject):
def __init__(self, handler=None):
super(self.__class__, self).__init__(handler)
self._name = "ActiveDirectory"
self.freenas_ad = None
def Enabled(self):
return activedirectory_enabled()
def Test(self):
try:
self.freenas_ad = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
if self.freenas_ad.connected():
return self._handler.Pass("ActiveDirectory")
else:
return self._handler.Fail("ActiveDirectory", "Unable to login to the Domain Controller.")
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("ActiveDirectory", error)
except Exception as e:
return self._handler.Fail("ActiveDirectory", str(e))
示例3: ActiveDirectory
# 需要导入模块: from freenasUI.common.freenasldap import FreeNAS_ActiveDirectory [as 别名]
# 或者: from freenasUI.common.freenasldap.FreeNAS_ActiveDirectory import connected [as 别名]
class ActiveDirectory(TestObject):
def __init__(self, handler=None):
super(self.__class__, self).__init__(handler)
self._name = "ActiveDirectory"
self.freenas_ad = None
def Enabled(self):
return activedirectory_enabled()
def Test(self):
try:
self.freenas_ad = FreeNAS_ActiveDirectory(flags=FLAGS_DBINIT)
if self.freenas_ad.connected():
return self._handler.Pass("ActiveDirectory")
else:
return self._handler.Fail("ActiveDirectory", "Unable to login to the Domain Controller.")
except Exception as e:
return self._handler.Fail("ActiveDirectory", str(e))