简体   繁体   English

Azure DevOps - 通过Api更新用户配置文件

[英]Azure DevOps - Update user profile via Api

I'm trying to perform a bulk update on a bunch of user profiles (displayName, mail, etc.) without having the users credentials instead with the highest privileges in Azure Active Directory and DevOps via the Azure DevOps REST API. 我正在尝试对一堆用户配置文件 (displayName,mail等) 执行批量更新,而不是通过Azure DevOps REST API获得Azure Active Directory和DevOps中的最高权限的用户凭据。 As the DevOps stays not in sync with the AAD. 由于DevOps与AAD保持不同步。

It looks like the Update method of a user can only map users to a new identity . 看起来用户的Update方法只能用户映射到新标识

This is what I have tried so far: 这是我到目前为止所尝试的:

private Task<HttpResponseMessage> PatchVstsUser(vssps.dev.azure.com.VstsUser user)
{

    var patchUser = new
    {
        displayName = user.Name,
        mailAddress = user.Mail,
        originId = user.AadId
    };

    return _devOpsGraphApi.PatchAsync($"users/{user.GraphDescriptor}?api-version=5.1-preview.1", patchUser);
 }

The API response with a 200 repsonse code but the acutal display name is not updated. 具有200个repsonse代码的API响应但不会更新实际显示名称。

How can I update eg the display name of a user using the Azure DevOps Rest API? 如何使用Azure DevOps Rest API更新例如用户的显示名称?

From network tab i was able to get the api fro updating user in Azure devops. 从网络选项卡,我能够获得Azure devops更新用户的api。

在此输入图像描述

Here is the request : 这是请求:

Request URL: https://####.###.azure.com/_apis/User/User
Request Method: PATCH
Status Code: 200 
Remote Address: ##.###.#.###:###
Referrer Policy: no-referrer-when-downgrade

Similarly you can get it for your organization. 同样,您可以为您的组织获取它。

Please note that its not a recommended way to updated the user. 请注意,这不是推荐的更新用户的方法。 Assuming your azure devops account is tagged to Azure Active directory, so you should be able to user graph API to updated user profile using below url. 假设您的azure devops帐户被标记为Azure Active目录,因此您应该能够使用以下URL将图形API用户更新为更新的用户配置文件。

PATCH /users/{id | userPrincipalName}

https://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=cs https://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=cs

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM