ldaptools.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:pizza-auth 作者: xxpizzaxx 项目源码 文件源码
def check_credentials(self, username, password):
        try:
            ldap_client = ldap.initialize(self.config["server"])
            ldap_client.set_option(ldap.OPT_REFERRALS,0)
            ldap_client.simple_bind_s("uid=%s,%s" % (username, self.config["memberdn"]), password)
        except ldap.INVALID_DN_SYNTAX:
            ldap_client.unbind()
            return False
        except ldap.INVALID_CREDENTIALS:
            ldap_client.unbind()
            return False
        except ldap.UNWILLING_TO_PERFORM:
            ldap_client.unbind()
            return False
        except ldap.SERVER_DOWN:
            ldap_client.unbind()
            raise ServerDownException()
            return False
        ldap_client.unbind()
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号