当前位置: 首页>>代码示例>>Python>>正文


Python FreeNAS_LDAP.open方法代码示例

本文整理汇总了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))
开发者ID:toastcomputer,项目名称:freenas,代码行数:36,代码来源:LDAP.py

示例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
开发者ID:binzyw,项目名称:freenas,代码行数:14,代码来源:notifier.py

示例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))
开发者ID:elovelan,项目名称:freenas,代码行数:21,代码来源:LDAP.py

示例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))
开发者ID:GitVendor,项目名称:freenas,代码行数:38,代码来源:LDAP.py


注:本文中的freenasUI.common.freenasldap.FreeNAS_LDAP.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。