2017-01-30 65 views
1

我知道如何创建AD B2C用户,并通过图形API将它们添加到组中。我在我的Azure函数中执行此操作。我想知道的是,是否可以创建用户并同时将它们添加到组中?如果不是,那么我想我将不得不处理创建用户的潜在案例,但无法添加到组中。这种情况有多可能?我试图确保我涵盖了所有失败条件下的所有基础,因此任何输入都将不胜感激。谢谢。创建AD用户并同时添加到组中?

回答

1

看起来好像你想使用Batch Processing这些类型的请求。

这里是他们的文章中发表的示例请求: 下面的例子显示了包含五个项目的批处理请求:

  1. 改变集,创建一个用户,[email protected]( POST)。此操作包括Prefer:response-no-content标头,用于禁止正在返回的新创建的用户。
  2. 用于更新新用户(PATCH)的Department和Job Title属性并设置其管理器导航属性(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": "[email protected]" 
    } 
    
    --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/[email protected]?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/[email protected]/$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/[email protected]/$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/[email protected]?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/[email protected]?api-version=1.5 HTTP/1.1 
    Accept: application/json 
    Host: graph.windows.net 
    
    --batch_36522ad7-fc75-4b56-8c71-56071383e77b-- 
    
+0

真棒,谢谢! – Architekt

相关问题