gpt4 book ai didi

azure - 创建AD用户并同时添加到组?

转载 作者:行者123 更新时间:2023-12-03 03:08:36 25 4
gpt4 key购买 nike

我知道如何创建 AD B2C 用户,以及如何通过图形 API 将其添加到组中。我正在我的 Azure 函数中执行此操作。我想知道的是,是否可以创建用户并将他们同时添加到组中?如果没有,那么我想我将不得不处理正在创建用户但无法添加到组中的潜在情况。这种情况发生的可能性有多大?我试图确保我涵盖了所有故障情况的所有基础,因此任何意见都将不胜感激。谢谢。

最佳答案

您似乎想使用 Batch Processing对于此类请求。

这是他们在文章中发布的示例请求:以下示例显示了包含五个项目的批处理请求:

  1. 创建用户的更改集 [email protected] (邮政)。此操作包含 Prefer: response-no-content header 以抑制返回新创建的用户。
  2. 更新新用户的部门和职务属性 (PATCH) 并设置其经理导航属性 (PUT) 的更改集。
  3. 对新用户经理的查询 (GET)。
  4. 删除新用户 (DELETE) 的更改集。
  5. 用户查询 (GET)。此操作将失败,因为用户已在上一步中删除。

    POST https://graph.windows.net/contoso.onmicrosoft.com/$batch?api-version=1.5 HTTP/1.1
    Authorization: Bearer ey … jQA
    Content-Type: multipart/mixed; boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77b
    Host: graph.windows.net
    Content-Length: 2961

    --batch_36522ad7-fc75-4b56-8c71-56071383e77b
    Content-Type: multipart/mixed; boundary=changeset_77162fcd-b8da-41ac-a9f8-9357efbbd620
    Content-Length: 631

    --changeset_77162fcd-b8da-41ac-a9f8-9357efbbd620
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    POST /contoso.onmicrosoft.com/users?api-version=1.5 HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Content-Length: 256
    Prefer: return-no-content
    Host: graph.windows.net

    {
    "accountEnabled": true,
    "displayName": "Test User",
    "mailNickname": "testuser",
    "passwordProfile": { "password" : "Test1234", "forceChangePasswordNextLogin": false },
    "userPrincipalName": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="47332234333234223507242829332834286928292a2e243528342821336924282a" rel="noreferrer noopener nofollow">[email protected]</a>"
    }

    --changeset_77162fcd-b8da-41ac-a9f8-9357efbbd620----batch_36522ad7-fc75-4b56-8c71-56071383e77b
    Content-Type: multipart/mixed; boundary=changeset_4b2cbfb7-011d-4edb-8bbf-e044f9830aaf
    Content-Length: 909

    --changeset_4b2cbfb7-011d-4edb-8bbf-e044f9830aaf
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    PATCH /contoso.onmicrosoft.com/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9adbcaaadacaabcab99bab6b7adb6aab6f7b6b7b4b0baabb6aab6bfadf7bab6b4" rel="noreferrer noopener nofollow">[email protected]</a>?api-version=1.5 HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Content-Length: 72
    Host: graph.windows.net

    {
    "department": "Engineering",
    "jobTitle": "Test Engineer"
    }

    --changeset_4b2cbfb7-011d-4edb-8bbf-e044f9830aaf
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    PUT /contoso.onmicrosoft.com/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b2c6d7c1c6c7c1d7c0f2d1dddcc6ddc1dd9cdddcdfdbd1c0ddc1ddd4c69cd1dddf" rel="noreferrer noopener nofollow">[email protected]</a>/$links/manager?api-version=1.5 HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Content-Length: 112
    Host: graph.windows.net

    {
    "url":"https://graph.windows.net/contoso.onmicrosoft.com/users/a71e4d1c-ce99-40dc-8d4b-390eac63e039"
    }

    --changeset_4b2cbfb7-011d-4edb-8bbf-e044f9830aaf----batch_36522ad7-fc75-4b56-8c71-56071383e77b
    Content-Type: application/http
    Content-Transfer-Encoding:binary

    GET /contoso.onmicrosoft.com/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d8acbdabacadabbdaa98bbb7b6acb7abb7f6b7b6b5b1bbaab7abb7beacf6bbb7b5" rel="noreferrer noopener nofollow">[email protected]</a>/$links/manager?api-version=1.5 HTTP/1.1
    Accept: application/json
    Host: graph.windows.net

    --batch_36522ad7-fc75-4b56-8c71-56071383e77b
    Content-Type: multipart/mixed; boundary=changeset_9a0b5878-0f4a-4f57-91c5-9792cdd5ef20
    Content-Length: 331

    --changeset_9a0b5878-0f4a-4f57-91c5-9792cdd5ef20
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    DELETE /contoso.onmicrosoft.com/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cabeafb9bebfb9afb88aa9a5a4bea5b9a5e4a5a4a7a3a9b8a5b9a5acbee4a9a5a7" rel="noreferrer noopener nofollow">[email protected]</a>?api-version=1.5 HTTP/1.1
    Accept: application/json
    Host: graph.windows.net


    --changeset_9a0b5878-0f4a-4f57-91c5-9792cdd5ef20----batch_36522ad7-fc75-4b56-8c71-56071383e77b
    Content-Type: application/http
    Content-Transfer-Encoding:binary

    GET /contoso.onmicrosoft.com/users/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1a5b4a2a5a4a2b4a391b2bebfa5bea2beffbebfbcb8b2a3bea2beb7a5ffb2bebc" rel="noreferrer noopener nofollow">[email protected]</a>?api-version=1.5 HTTP/1.1
    Accept: application/json
    Host: graph.windows.net

    --batch_36522ad7-fc75-4b56-8c71-56071383e77b--

关于azure - 创建AD用户并同时添加到组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41929274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com