Exportera (0) Skriv ut
Visa allt
EN
Det här innehållet finns inte tillgängligt på ditt språk men här finns den engelska versionen,

Create User(s)

Updated: April 21, 2014

The Create User(s) operation creates one or more new users in the directory.

The immutableId property was added to a User object for requests using version 2013-11-08 or newer. When creating a user with version 2013-11-08 or newer, this property must be specified if the userPrincipalName (UPN) includes a federated domain.

The request may be constructed as follows. Replace mytenantdomain with the domain of your Azure Active Directory tenant, such as contoso.onmicrosoft.com. The api-version query string parameter is required. The examples in this topic use the tenant domain to address the tenant. For other ways of addressing the tenant, see Addressing Entities and Operations in the Graph API.

 

HTTP Method Request URI HTTP Version

POST

https://graph.windows.net/mytenantdomain/users?api-version=2013-04-05

HTTP 1.1

 

Request Header Description

Authorization

Required. A bearer token issued by Azure Access Control. See Azure AD Graph Authentication for more information.

Content-Type

Required. The media type of the content in the request body.

Content-Length

Required. The length of the request in bytes.

One or more User entities with the minimum properties specified in the User topic. The password specified must meet the tenant’s password complexity requirements. For more information about password complexity requirements, see the User topic. The sample request below shows the minimum properties required to successfully create a user.

The following sample request creates a new user in the directory using version 2013-04-05:

POST https://graph.windows.net/contoso.onmicrosoft.com/users?api-version=2013-04-05 HTTP/1.1
Authorization: Bearer eyJ0eX ... FWSXfwtQ
Content-Type: application/json
Host: graph.windows.net
Content-Length: 252

{
    "accountEnabled": true,
    "displayName": "Alex Wu",
    "mailNickname": "AlexW",
    "passwordProfile": { "password" : "Test1234", "forceChangePasswordNextLogin": false },
    "userPrincipalName": "Alex@contoso.onmicrosoft.com"
}


The following sample request creates a new user in the directory using version 2013-11-08, specifying the immutableId property:

POST https://graph.windows.net/contoso.onmicrosoft.com/users?api-version=2013-11-08 HTTP/1.1
Authorization: Bearer eyJ0eX ... FWSXfwtQ
Content-Type: application/json
Host: graph.windows.net
Content-Length: 293

{
    "accountEnabled": true,
    "displayName": "Alex Wu",
    "mailNickname": "AlexW",
    "passwordProfile": { "password" : "Test1234", "forceChangePasswordNextLogin": false },
    "userPrincipalName": "Alex@contoso.onmicrosoft.com"
    "immutableId": "6SNZnFLe6jOI3n68hjO5zA=="
}


A successful operation returns status code 201 Created.

 

Response Header Description

Location

The URI of the created User, which includes an Object Id.

ocp-aad-diagnostics-server-name

The identifier for the server that performed the requested operation.

ocp-aad-session-key

The key that identifies the current session with the directory service.

The following sample response is received when the sample request above is sent.

HTTP/1.1 201 Created
Cache-Control: no-cache
Content-Length: 982
Content-Type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8
Location: https://directory.windows.net/contoso.onmicrosoft.com/directoryObjects/4e971521-101a-4311-94f4-0917d7218b4e/Microsoft.WindowsAzure.ActiveDirectory.User
Server: Microsoft-IIS/7.5
ocp-aad-diagnostics-server-name: XDALV0qN1u6zqj4Uo0sPtNcrP2gqE1lnhxOWAGczrDE=
request-id: 65230a2c-0477-4fb8-9cd5-adb796f8eb29
client-request-id: ae924da9-55ea-433a-b14e-da2ef9fcd6af
x-ms-dirapi-data-contract-version: 1.0
ocp-aad-session-key: eHD4TUXUT8mNc01h-PGrQAw0kfAGmLi_T64SX_h1OGu8mTPZXTZfa6HCCDc7-r7pMultoOn3oDO0ciBl8PzNAkRHkc2BD-tUnUJI3bYWT7T3YxjW2s0dortRi6yKrCf4Qx9m67uJmCT5FhqZsgNAvw.FujkHs6N4TinxXNQi_y41v8vDIrI1DKDQXyhexHvdY8
X-Content-Type-Options: nosniff
DataServiceVersion: 3.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By: ARR/2.5
X-Powered-By: ASP.NET
Date: Wed, 27 Mar 2013 22:59:47 GMT

{
    "odata.metadata": "https://graph.windows.net/contoso.onmicrosoft.com/$metadata#directoryObjects/Microsoft.WindowsAzure.ActiveDirectory.User/@Element",
    "odata.type": "Microsoft.WindowsAzure.ActiveDirectory.User",
    "objectType": "User",
    "objectId": "4e971521-101a-4311-94f4-0917d7218b4e",
    "accountEnabled": true,
    "assignedLicenses": [],
    "assignedPlans": [],
    "city": null,
    "country": null,
    "department": null,
    "dirSyncEnabled": null,
    "displayName": "Alex Wu",
    "facsimileTelephoneNumber": null,
    "givenName": null,
    "jobTitle": null,
    "lastDirSyncTime": null,
    "mail": null,
    "mailNickname": "AlexW",
    "mobile": null,
    "otherMails": [],
    "passwordPolicies": null,
    "passwordProfile": null,
    "physicalDeliveryOfficeName": null,
    "postalCode": null,
    "preferredLanguage": null,
    "provisionedPlans": [],
    "provisioningErrors": [],
    "proxyAddresses": [],
    "state": null,
    "streetAddress": null,
    "surname": null,
    "telephoneNumber": null,
    "thumbnailPhoto@odata.mediaContentType": "image",
    "usageLocation": null,
    "userPrincipalName": "Alex@contoso.onmicrosoft.com"
}

See Also

Concepts

User

Visa:
© 2014 Microsoft