ldapauth.py 文件源码

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

项目:nav 作者: UNINETT 项目源码 文件源码
def get_real_name(self):
        """
        Attempt to retrieve the LDAP Common Name of the given login name.
        """
        encoding = _config.get('ldap', 'encoding')
        user_dn = self.get_user_dn().encode(encoding)
        name_attr = _config.get('ldap', 'name_attr')
        try:
            res = self.ldap.search_s(user_dn, ldap.SCOPE_BASE,
                                     '(objectClass=*)', [name_attr])
        except ldap.LDAPError:
            _logger.exception("Caught exception while retrieving user name "
                              "from LDAP, returning None as name")
            return None

        # Just look at the first result record, since we are searching for
        # a specific user
        record = res[0][1]
        name = record[name_attr][0]
        return name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号