rbuserdb.py 文件源码

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

项目:useradm 作者: redbrick 项目源码 文件源码
def get_staff_byid(self, usr, override=0):
        """Populate RBUser object with data from user with given id in
        staff database.
        By default will only populate RBUser attributes that have no
        value (None) unless override is enabled.
        Not all staff are in the database, so only raise a
        RBWarningError if user does not exist."""

        # Staff ID is not consistently set. It will either be in the cn
        # or in the gecos, so try both.
        #
        res = self.ldap_dcu.search_s(
            rbconfig.ldap_dcu_staff_tree, ldap.SCOPE_SUBTREE,
            '(|(cn=%s)(gecos=*,*%s))' % (usr.id, usr.id))
        if res:
            self.set_user_dcu(usr, res[0], override)
            self.set_user_dcu_staff(usr, res[0], override)
        else:
            raise RBWarningError(
                "Staff id '%s' does not exist in database" % usr.id)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号