lcmldap.py 文件源码

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

项目:umanager 作者: lcm-unimi 项目源码 文件源码
def __init__(self, uri, cn, dc, secret):
        self.conn   = None
        self.uri    = uri
        self.dc     = dc
        self.secret = secret
        try:
            self.conn = ldap.initialize(self.uri)
            self.conn.protocol_version = ldap.VERSION3
            self.conn.simple_bind_s(cn+","+self.dc,self.secret)
            print("Connection established.")
        except ldap.INVALID_CREDENTIALS:
            print("Your username or password is incorrect.")
            sys.exit()
        except ldap.LDAPError as e:
            if type(e.message) == dict and e.message.has_key('desc'):
                print(e.message['desc'])
            else: print(e)
            sys.exit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号