有没有一种方法可以使用rest api在特定的Azure Devops项目中获得用户权限? [英] Is there a way to get user permissions in a specific Azure Devops Project using rest api?

查看:123
本文介绍了有没有一种方法可以使用rest api在特定的Azure Devops项目中获得用户权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查特定Azure Devops项目中用户的权限.有没有一种可能的方式来获得它?据我所知,项目级别的权限与组织级别的权限不同.谢谢.

Hi I want to check the permissions of a user in a specific Azure Devops Project. Is there a possible way to get it? As far as I know project level permission is different than organization level permissions. Thanks.

已经测试了一些其他的api,但是我仍然没有项目级别的权限.

Already test some several rest apis but still I can't have the project level permission.

推荐答案

当前没有在项目中获得用户许可的现成的rest api.

There is currently no out-of-the-box rest api to get the user's permission in project.

要实现此需求,您可以使用以下rest api:

To achieve this demand, you can use this rest api :

https://dev.azure.com/{org}/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1

请求正文:

{
    "contributionIds": ["ms.vss-admin-web.org-admin-permissions-pivot-data-provider"],
    "dataProviderContext": {
        "properties": {
            "subjectDescriptor": "msa.ZjE1ZTk0NmMtOTI4OS03Mjg5LTljMGUtMDIwMTdlYmM2Nzhj",
            "sourcePage": {
                "url": "https://dev.azure.com/xxx/xxxx/_settings/permissions",
                "routeId": "ms.vss-admin-web.project-admin-hub-route",
                "routeValues": {
                    "action": "Execute",
                    "adminPivot": "permissions",
                    "controller": "ContributedPage",
                    "project": "XXX",
                    "serviceHost": "0933e8b2-f504-4b7e-9e9e-xxxxx (xxx)"
                }
            }
        }
    }
} 

您可以通过在浏览器中按F12然后选择Network来跟踪此rest api,然后查找响应主体包括返回的权限的记录.从此记录中,您可以获得其余的api和请求正文.

You can track this rest api by press F12 in browser then select Network .Then looking for the record that response body included returned permission. From this record you can get the rest api and request body.

我用postman进行了测试,使用此api,我可以在项目中成功获得用户的许可.如下所示:

I tested with postman , with this api ,I can successful get user's permission in project. As shown below:

这篇关于有没有一种方法可以使用rest api在特定的Azure Devops项目中获得用户权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆