ユーザーに対する操作 |Graph API リファレンス

適用対象: Graph API | Azure Active Directory

このトピックでは、Azure Active Directory (AD) Graph API を使用するユーザーに対する操作の実行方法について説明します。 Azure AD Graph API を使用して、ユーザーの作成、読み取り、更新、および削除を行うことができます。 また、ユーザーの他のディレクトリ エンティティに対する関係を照会および変更することもできます。 たとえば、ユーザーのマネージャーの割り当て、ユーザーの直属の部下の照会、およびグループ メンバーシップ、アプリケーション ロール、ユーザーに割り当てられているデバイスの管理などを行うことができます。

Graph API は、ユーザー、グループ、組織の連絡先、アプリケーションなど、Azure Active Directory のディレクトリ オブジェクトへのプログラムによるアクセスを提供する OData 3.0 対応 REST API です。

重要

Azure AD Graph API の機能は、統合 API の Microsoft Graph からも使用できます。Microsoft Graph には、Outlook、OneDrive、OneNote、Planner、Office Grap など他の Microsoft サービスの API も含まれており、これらはすべて単一のアクセス トークンを使用して単一のエンドポイントからアクセスします。 テストします。

ユーザーに対する REST 操作の実行

Graph API を使用してユーザーに対して操作を実行するには、サポートされているメソッド (GET、POST、PATCH、PUT、または DELETE) を指定した HTTP 要求を、ユーザー リソース コレクション、特定のユーザー、ユーザーのナビゲーション プロパティまたはユーザーに対して呼び出すことができる関数またはアクションを対象とするエンドポイントに送信します。

Graph API の要求では、次の基本 URL を使用します。

https://graph.windows.net/{tenant_id}/{resource_path}?{api_version}[odata_query_parameters]

重要

Graph API に送信する要求は、適切な形式で指定し、Graph API の有効なエンドポイントおよびバージョンを対象として、Azure AD から取得された有効なアクセス トークンを Authorization ヘッダーに含める必要があります。 Graph API での要求の作成および応答の受信の詳細については、「[Operations Overview]」を参照してください。

指定するリソース パスは、テナント内のすべてのユーザーのコレクション、個々のユーザー、特定のユーザーのナビゲーション プロパティのいずれを対象にするかによって異なります。

  • /users では、ユーザー リソース コレクションが対象となります。 このリソースのパスを使用すると、テナントのすべてのユーザーまたはユーザーのフィルター処理された一覧を読み取ったり、テナントに 1 つ以上の新しいユーザーを作成できます。
  • /users/{user_id} では、テナント内の個々のユーザーが対象となります。 対象ユーザーのオブジェクト ID (GUID) またはユーザー プリンシパル名 (UPN) として user_id を指定します。 このリソース パスを使用して、ユーザーの宣言されたプロパティを取得したり、ユーザーの宣言されたプロパティを変更したり、ユーザーを削除したりすることができます。
  • /users/{user_id}/{property} では、ユーザーの指定されたナビゲーション プロパティが対象となります。 これを使用して、指定したユーザーの対象となるナビゲーション プロパティによって参照されるオブジェクトを取得できます。 : この形式のアドレス指定は読み取りの場合にのみ使用できます。
  • /users/{user_id}/$links/{property} では、ユーザーの指定されたナビゲーション プロパティが対象となります。 この形式のアドレス指定を使用すると、ナビゲーション プロパティの読み取りと変更の両方を行うことができます。 読み取り時には、プロパティによって参照されるオブジェクトは、応答本文で 1 つ以上のリンクとして返されます。 書き込み時には、オブジェクトは、要求本文で 1 つ以上のリンクとして指定されます。

たとえば、次の要求は、指定したユーザーのマネージャーへのリンクを返します。

GET https://graph.windows.net/myorganization/users/john@contoso.onmicrosoft.com/$links/manager?api-version=1.6

: me エイリアスを使用すると、サインインしているユーザーを対象にすることができます。 me エイリアスを使用する操作の実行の詳細については、「サインインしているユーザーに対する操作」を参照してください。

ユーザーに対する基本操作

ユーザーおよびその宣言されたプロパティに対する基本的な作成、読み取り、更新、および削除 (CRUD) 操作は、ユーザー リソース コレクションまたは特定のユーザーを対象として指定することで実行できます。 以下ではその方法について説明します。


複数のユーザーの取得

ユーザーのコレクションを取得します。 OData クエリ パラメーターを要求に追加して、応答をフィルター処理、並べ替え、ページングすることができます。 詳細については、「[Supported Queries, Filters, and Paging Options]」を参照してください。

成功した場合、[User] オブジェクトのコレクションが返されます。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

{
    "api":  "Users",
    "operation":    "get users", 
     "showComponents": {        
        "codeGenerator": "true",
        "tryFeature": "true"      
    } 
}

1 人のユーザーの取得

指定したユーザーを取得します。 オブジェクト ID (GUID) またはユーザー プリンシパル名 (UPN) を使用して、対象ユーザーを指定できます。

成功した場合、指定したユーザーの [User] オブジェクトが返されます。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

{
    "api":  "Users",
    "operation":    "get user by id",
     "showComponents": {        
        "codeGenerator":    "true",
        "tryFeature": "true"      
    } 
}

ユーザーのサムネイル写真の取得

指定したユーザーのサムネイル写真を、thumbnailPhoto プロパティから取得します。 オブジェクト ID (GUID) またはユーザー プリンシパル名 (UPN) を使用して、対象ユーザーを指定できます。

成功した場合、指定したユーザーのサムネイル写真が返されます。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

重要: メディアの種類は、Azure AD に格納されているイメージの種類に依存し、Content-Type ヘッダーで返されます (例: image/jpeg)。 メディアの種類を特定できない場合、Graph API は Content-Type として */* を返します。 Graph API では、メディア (イメージ) の種類の変換は行われません。

{
    "api":  "Users",
    "operation":    "get user thumbnail photo",
     "showComponents": {        
        "codeGenerator":    "false",
        "tryFeature": "false"      
    } 
}

ユーザーの作成 (職場または学校アカウント)

職場または学校アカウントを作成して、テナントにユーザーを追加します。 このようなユーザーは、組織アカウントまたは組織ユーザーとも呼ばれます。 要求本文には、作成するユーザーのプロパティが含まれます。 少なくとも、ユーザーの必須プロパティを指定する必要があります。 必要に応じて、他の書き込み可能プロパティも指定できます。ただし、creationTypesignInNames は例外で、これらはローカル アカウントに対してのみ有効です。 Azure Active Directory B2C テナントにローカル アカウント ユーザーを追加する方法については、「ユーザーの作成 (ローカル アカウント)」を参照してください。

次の表では、ユーザーを作成するときに必要なプロパティを示します。

必須パラメーター 説明
accountEnabled boolean アカウントが有効な場合は true、無効な場合は false
displayName string ユーザーのアドレス帳に表示される名前。
immutableId string ユーザーの userPrincipalName (UPN) プロパティでフェデレーション ドメインを使用している場合、新しいユーザー アカウントを作成するときにのみ指定する必要があります。
mailNickname string ユーザーのメールの別名。
passwordProfile [PasswordProfile] ユーザーのパスワード プロファイル。
userPrincipalName string ユーザー プリンシパル名 (someuser@contoso.com)。 ユーザー プリンシパル名には、テナントの確認済みドメインのいずれかが含まれる必要があります。

成功した場合、新しく作成された [User] が返されます。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

{
    "api":  "Users",
    "operation":    "create user" 
}

ユーザーの作成 (ローカル アカウント)

バージョン 1.6 以降の Graph API は、Azure Active Directory B2C テナントのローカル アカウント ユーザーの作成をサポートします。 テナントの確認済みドメインの 1 つを含む電子メール アドレスでサインインする必要がある職場または学校アカウントに関連付けられているユーザーとは異なり、ローカル アカウント ユーザーは、アプリ固有の資格情報でのサインインをサポートしています (例: サード パーティの電子メール アドレス、アプリ固有のユーザー名)。 Azure Active Directory B2C の詳細については、「Azure Active Directory B2C のドキュメント」を参照してください。

要求本文には、作成するローカル アカウント ユーザーのプロパティが含まれます。 少なくとも、ローカル アカウント ユーザーの必須プロパティを指定する必要があります。 これらは、次の表でわかるように、職場または学校アカウントの必須プロパティとは若干異なります。 ローカル アカウント ユーザーの場合、creationType プロパティを指定してユーザーがローカル アカウントであることを示し、signInNames プロパティを指定してユーザーのサインイン名を渡す必要があります。 必須プロパティに加えて、必要に応じて、[User] エンティティの他の書き込み可能プロパティを指定できます。ただし、一般には、アプリで定義された拡張プロパティおよび [User] エンティティで使用可能なプロパティのサブセットに限られます。 ローカル アカウント ユーザーにライセンスまたはサブスクリプションを割り当てることはできません。

次の表では、ローカル アカウント ユーザーを作成するときに必要なプロパティを示します。

必須パラメーター 説明
accountEnabled boolean アカウントが有効な場合は true、無効な場合は false
creationType string ローカル アカウント ユーザーを作成する場合は、"LocalAccount" に設定する必要があります。 : ベータ版では "NameCoexistence" と指定します。
displayName string ユーザーのアドレス帳に表示される名前。
passwordProfile [PasswordProfile] ユーザーのパスワード プロファイル。
signInNames collection([SignInName]) ユーザーのサインイン名を指定する 1 つまたは複数の [SignInName] レコード。 各サインイン名は、会社またはテナント全体で一意である必要があります。 : ベータ版の alternativeSignInNamesInfo から名前が変更されています。

成功した場合、新しく作成された [User] が返されます。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

{
    "api":  "Users2",
    "operation":    "create local account user" 
}

ユーザーの更新

ユーザーのプロパティを更新します。 要求本文に任意の書き込み可能な [User] プロパティを指定します。 指定したプロパティのみが変更されます。

成功した場合、応答本文は返されません。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

{
    "api":  "Users",
    "operation":    "update user"
}

ユーザーのパスワードのリセット

ユーザーのパスワードをリセットします。 ユーザーのパスワードのリセットは、ユーザー更新操作の特殊なケースです。 [User] の passwordProfile プロパティを指定します。 要求には、テナントのパスワード複雑性ポリシーを満たしているパスワードを指定する、有効な [PasswordProfile] オブジェクトが含まれます。 パスワード ポリシーでは、通常、パスワードの複雑性、長さ、および再利用の制約が適用されます。 詳細については、「[PasswordProfile]」トピックを参照してください。

成功した場合、応答本文は返されません。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

{
    "api":  "Users2",
    "operation":    "reset user password"
}

ユーザーの削除

ユーザーを削除します。 削除したユーザーは、回復できない可能性があります。

成功した場合、応答本文は返されません。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

{
    "api":  "Users",
    "operation":    "delete user"
}

ユーザー ナビゲーション プロパティに対する操作

ユーザーと、ユーザーのマネージャー、直属のグループ メンバーシップ、直属の部下などのディレクトリ内の他のオブジェクトとの関係は、ナビゲーション プロパティを介して公開されます。 これらの関係は読み取ることができます。また、場合によっては、要求でこれらのナビゲーション プロパティを対象として指定することで、関係を変更できます。

ユーザーのマネージャーの取得

ユーザーのマネージャーを、manager ナビゲーション プロパティから取得します。

成功した場合は、ユーザーのマネージャーとして割り当てられている [User] または [Contact] へのリンクが返されます。失敗した場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

: URL から "$links" セグメントを削除すると、リンクの代わりに [User] または [Contact] オブジェクトを取得できます。

{
    "api":  "Users",
    "operation":    "get user manager link",
     "showComponents": {        
        "codeGenerator":    "true",
        "tryFeature": "true"      
    } 
}

ユーザーのマネージャーの割り当て

manager プロパティを使用して、ユーザーのマネージャーを割り当てます。 ユーザーまたは連絡先を割り当てることができます。 要求本文には、割り当てる [User] または [Contact] へのリンクが含まれます。

成功した場合、応答本文は返されません。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

{
    "api":  "Users",
    "operation":    "update user manager"
}

ユーザーの直属の部下の取得

directReports ナビゲーション プロパティから、ユーザーの直属の部下を取得します。

成功した場合、このユーザーがマネージャーとして割り当てられている [User] および [Contact] へのリンクのコレクションが返されます。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

: URL から "$links" セグメントを削除すると、リンクの代わりにユーザーおよび連絡先の [DirectoryObject] を取得できます。

{
    "api":  "Users",
    "operation":    "get user direct reports links",
     "showComponents": {        
        "codeGenerator":    "true",
        "tryFeature": "true"      
    } 
}

ユーザーのグループおよびディレクトリ ロール メンバーシップの取得 (推移的)

memberOf ナビゲーション プロパティから、ユーザーのグループおよびディレクトリ ロール メンバーシップを取得します。

このプロパティは、ユーザーが直接メンバーになっているグループまたはディレクトリ ロールのみを返します。 ユーザーが直接的または推移的なメンバーシップを持つすべてのグループを取得するには、[getMemberGroups] 関数を呼び出します。 ユーザーが直接的または推移的なメンバーシップを持つすべてのグループまたはディレクトリ ロールを取得するには、[getMemberObjects] 関数を呼び出します。

成功した場合、このユーザーがメンバーである [Group] および [DirectoryRole] へのリンクのコレクションが返されます。それ以外の場合は、応答本文にエラーの詳細が含まれます。 エラーの詳細については、「[Error Codes and Error Handling]」を参照してください。

: URL から "$links" セグメントを削除すると、リンクの代わりにグループおよびディレクトリ ロールの [DirectoryObject] オブジェクトを取得できます。

{
    "api":  "Users",
    "operation":    "get user memberOf links",
     "showComponents": {        
        "codeGenerator":    "true",
        "tryFeature": "true"      
    } 
}

その他のナビゲーション プロパティ

前述の同じパターンを使用して、ユーザーで公開されるその他のナビゲーション プロパティを対象にすることができます。 読み取り専用のプロパティや変更できるプロパティがあります。 ユーザー ナビゲーション プロパティの詳細については、「[User]」を参照してください。


ユーザーに対する関数とアクション

ユーザーに対して、以下の関数またはアクションのいずれかを呼び出すことができます。

ユーザーにライセンスを割り当てる

[assignLicense] アクションを呼び出して、ユーザーへのライセンスの割り当て、ライセンスの削除、ユーザーに対する特定のプランの有効化または無効化を行うことができます。

サインインしているユーザーのパスワードの変更

サインインしているユーザーに対して [changePassword] アクションを呼び出すと、ユーザーにパスワードを変更させることができます。

特定のグループのメンバーシップの確認 (推移的)

[isMemberOf] 関数を呼び出すと、特定のグループのメンバーシップを確認できます。 この確認は推移的です。

グループ リストのメンバーシップの確認 (推移的)

[checkMemberGroups] 関数を呼び出すと、グループ リストのメンバーシップを確認できます。 この確認は推移的です。

すべてのグループ メンバーシップの取得 (推移的)

[getMemberGroups] 関数を呼び出すと、ユーザーがメンバーであるすべてのグループを取得できます。 ユーザーが直接のメンバーになっているグループのみを返す memberOf ナビゲーション プロパティの読み取りとは異なり、確認は推移的です。

すべてのグループおよびディレクトリ ロール メンバーシップの取得 (推移的)

[getMemberObjects] 関数を呼び出すと、ユーザーがメンバーであるすべてのグループとディレクトリ ロールを取得できます。 ユーザーが直接のメンバーになっているグループのみを返す memberOf ナビゲーション プロパティの読み取りとは異なり、確認は推移的です。


その他のリソース

  • Graph API でサポートされる機能、およびプレビュー機能の詳細については、「Graph API の概念」を参照してください。

Get users

GET https://graph.windows.net/myorganization/users?api-version[&$filter]

Parameters

Parameter Type Value Notes
Query
api-version string 1.6 The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
$filter string startswith(displayName,'A') A filter to apply to the request. Optional. (Leave blank to omit the $filter parameter.)

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.User",
  "value": [
    {
      "odata.type": "Microsoft.DirectoryServices.User",
      "objectType": "User",
      "objectId": "e61ff361-5baf-41f0-b2fd-380a6a5e406a",
      "deletionTimestamp": null,
      "accountEnabled": true,
      "signInNames": [],
      "assignedLicenses": [
        {
          "disabledPlans": [],
          "skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
        }
      ],
      "assignedPlans": [
        {
          "assignedTimestamp": "2014-10-14T02:54:57Z",
          "capabilityStatus": "Enabled",
          "service": "exchange",
          "servicePlanId": "efb87545-963c-4e0d-99df-69c6916d9eb0"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:57Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "5dbe027f-2339-4123-9542-606e4d348a72"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:57Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "e95bec33-7c88-4a70-8e19-b10bd9d0c014"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:57Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftCommunicationsOnline",
          "servicePlanId": "0feaeb32-d00e-4d66-bd5a-43b5b83db82c"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:57Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftOffice",
          "servicePlanId": "43de0ff5-c92c-492b-9116-175376d08c38"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:57Z",
          "capabilityStatus": "Enabled",
          "service": "RMSOnline",
          "servicePlanId": "bea4c11e-220a-4e6d-8eb8-8ea15d019f90"
        }
      ],
      "city": null,
      "country": null,
      "creationType": null,
      "department": null,
      "dirSyncEnabled": null,
      "displayName": "Rob Young",
      "facsimileTelephoneNumber": null,
      "givenName": "Rob",
      "immutableId": null,
      "jobTitle": null,
      "lastDirSyncTime": null,
      "mail": "roby@a830edad9050849NDA1.onmicrosoft.com",
      "mailNickname": "roby",
      "mobile": null,
      "onPremisesSecurityIdentifier": null,
      "otherMails": [],
      "passwordPolicies": "None",
      "passwordProfile": null,
      "physicalDeliveryOfficeName": null,
      "postalCode": null,
      "preferredLanguage": null,
      "provisionedPlans": [
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "exchange"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftCommunicationsOnline"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftOffice"
        }
      ],
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:roby@a830edad9050849NDA1.onmicrosoft.com"
      ],
      "sipProxyAddress": "roby@a830edad9050849NDA1.onmicrosoft.com",
      "state": null,
      "streetAddress": null,
      "surname": "Young",
      "telephoneNumber": null,
      "usageLocation": "US",
      "userPrincipalName": "roby@a830edad9050849NDA1.onmicrosoft.com",
      "userType": "Member"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.User",
      "objectType": "User",
      "objectId": "fec3faba-6a15-4e3e-8a9e-5c63f7510377",
      "deletionTimestamp": null,
      "accountEnabled": true,
      "signInNames": [],
      "assignedLicenses": [
        {
          "disabledPlans": [],
          "skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
        }
      ],
      "assignedPlans": [
        {
          "assignedTimestamp": "2014-10-14T02:54:32Z",
          "capabilityStatus": "Enabled",
          "service": "exchange",
          "servicePlanId": "efb87545-963c-4e0d-99df-69c6916d9eb0"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:32Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "5dbe027f-2339-4123-9542-606e4d348a72"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:32Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "e95bec33-7c88-4a70-8e19-b10bd9d0c014"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:32Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftCommunicationsOnline",
          "servicePlanId": "0feaeb32-d00e-4d66-bd5a-43b5b83db82c"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:32Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftOffice",
          "servicePlanId": "43de0ff5-c92c-492b-9116-175376d08c38"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:32Z",
          "capabilityStatus": "Enabled",
          "service": "RMSOnline",
          "servicePlanId": "bea4c11e-220a-4e6d-8eb8-8ea15d019f90"
        }
      ],
      "city": "Pittsburgh",
      "country": "United States",
      "creationType": null,
      "department": "Finance",
      "dirSyncEnabled": null,
      "displayName": "Katie Jordan",
      "facsimileTelephoneNumber": null,
      "givenName": "Katie",
      "immutableId": null,
      "jobTitle": "Auditor",
      "lastDirSyncTime": null,
      "mail": "katiej@a830edad9050849NDA1.onmicrosoft.com",
      "mailNickname": "katiej",
      "mobile": null,
      "onPremisesSecurityIdentifier": null,
      "otherMails": [],
      "passwordPolicies": "None",
      "passwordProfile": null,
      "physicalDeliveryOfficeName": "12/1110",
      "postalCode": "15212",
      "preferredLanguage": "en-US",
      "provisionedPlans": [
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "exchange"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftCommunicationsOnline"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftOffice"
        }
      ],
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:katiej@a830edad9050849NDA1.onmicrosoft.com"
      ],
      "sipProxyAddress": "katiej@a830edad9050849NDA1.onmicrosoft.com",
      "state": "PA",
      "streetAddress": "30 Isabella St., Second Floor",
      "surname": "Jordan",
      "telephoneNumber": "+1 412 555 0109",
      "usageLocation": "US",
      "userPrincipalName": "katiej@a830edad9050849NDA1.onmicrosoft.com",
      "userType": "Member"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.User",
      "objectType": "User",
      "objectId": "6816d6c4-5c13-44a5-baaa-2dae2cc07461",
      "deletionTimestamp": null,
      "accountEnabled": true,
      "signInNames": [],
      "assignedLicenses": [
        {
          "disabledPlans": [],
          "skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
        }
      ],
      "assignedPlans": [
        {
          "assignedTimestamp": "2014-10-14T02:55:27Z",
          "capabilityStatus": "Enabled",
          "service": "exchange",
          "servicePlanId": "efb87545-963c-4e0d-99df-69c6916d9eb0"
        },
        {
          "assignedTimestamp": "2014-10-14T02:55:27Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "5dbe027f-2339-4123-9542-606e4d348a72"
        },
        {
          "assignedTimestamp": "2014-10-14T02:55:27Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "e95bec33-7c88-4a70-8e19-b10bd9d0c014"
        },
        {
          "assignedTimestamp": "2014-10-14T02:55:27Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftCommunicationsOnline",
          "servicePlanId": "0feaeb32-d00e-4d66-bd5a-43b5b83db82c"
        },
        {
          "assignedTimestamp": "2014-10-14T02:55:27Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftOffice",
          "servicePlanId": "43de0ff5-c92c-492b-9116-175376d08c38"
        },
        {
          "assignedTimestamp": "2014-10-14T02:55:27Z",
          "capabilityStatus": "Enabled",
          "service": "RMSOnline",
          "servicePlanId": "bea4c11e-220a-4e6d-8eb8-8ea15d019f90"
        }
      ],
      "city": "Iselin",
      "country": "United States",
      "creationType": null,
      "department": "Sales & Marketing",
      "dirSyncEnabled": null,
      "displayName": "Pavel Bansky",
      "facsimileTelephoneNumber": null,
      "givenName": "Pavel",
      "immutableId": null,
      "jobTitle": "VP Sales",
      "lastDirSyncTime": null,
      "mail": "pavelb@a830edad9050849NDA1.onmicrosoft.com",
      "mailNickname": "pavelb",
      "mobile": null,
      "onPremisesSecurityIdentifier": null,
      "otherMails": [],
      "passwordPolicies": "None",
      "passwordProfile": null,
      "physicalDeliveryOfficeName": "19/3123",
      "postalCode": "8830",
      "preferredLanguage": null,
      "provisionedPlans": [
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "exchange"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftCommunicationsOnline"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftOffice"
        }
      ],
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:pavelb@a830edad9050849NDA1.onmicrosoft.com"
      ],
      "sipProxyAddress": "pavelb@a830edad9050849NDA1.onmicrosoft.com",
      "state": "NJ",
      "streetAddress": "101 Wood Avenue South, Suite 900",
      "surname": "Bansky",
      "telephoneNumber": "+1 732 555 0102",
      "usageLocation": "US",
      "userPrincipalName": "pavelb@a830edad9050849NDA1.onmicrosoft.com",
      "userType": "Member"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.User",
      "objectType": "User",
      "objectId": "13addec1-c5ae-47f5-a1fe-202be14b1570",
      "deletionTimestamp": null,
      "accountEnabled": true,
      "signInNames": [],
      "assignedLicenses": [
        {
          "disabledPlans": [],
          "skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
        }
      ],
      "assignedPlans": [
        {
          "assignedTimestamp": "2014-10-14T02:54:04Z",
          "capabilityStatus": "Enabled",
          "service": "exchange",
          "servicePlanId": "efb87545-963c-4e0d-99df-69c6916d9eb0"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:04Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "5dbe027f-2339-4123-9542-606e4d348a72"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:04Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "e95bec33-7c88-4a70-8e19-b10bd9d0c014"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:04Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftCommunicationsOnline",
          "servicePlanId": "0feaeb32-d00e-4d66-bd5a-43b5b83db82c"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:04Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftOffice",
          "servicePlanId": "43de0ff5-c92c-492b-9116-175376d08c38"
        },
        {
          "assignedTimestamp": "2014-10-14T02:54:04Z",
          "capabilityStatus": "Enabled",
          "service": "RMSOnline",
          "servicePlanId": "bea4c11e-220a-4e6d-8eb8-8ea15d019f90"
        }
      ],
      "city": "Tulsa",
      "country": "United States",
      "creationType": null,
      "department": "Sales & Marketing",
      "dirSyncEnabled": null,
      "displayName": "Garth Fort",
      "facsimileTelephoneNumber": null,
      "givenName": "Garth",
      "immutableId": null,
      "jobTitle": "Web Marketing Manager",
      "lastDirSyncTime": null,
      "mail": "garthf@a830edad9050849NDA1.onmicrosoft.com",
      "mailNickname": "garthf",
      "mobile": null,
      "onPremisesSecurityIdentifier": null,
      "otherMails": [],
      "passwordPolicies": "None",
      "passwordProfile": null,
      "physicalDeliveryOfficeName": "20/1101",
      "postalCode": "74133",
      "preferredLanguage": "en-US",
      "provisionedPlans": [
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "exchange"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftCommunicationsOnline"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftOffice"
        }
      ],
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:garthf@a830edad9050849NDA1.onmicrosoft.com"
      ],
      "sipProxyAddress": "garthf@a830edad9050849NDA1.onmicrosoft.com",
      "state": "OK",
      "streetAddress": "7633 E. 63rd Place, Suite 300",
      "surname": "Fort",
      "telephoneNumber": "+1 918 555 0101",
      "usageLocation": "US",
      "userPrincipalName": "garthf@a830edad9050849NDA1.onmicrosoft.com",
      "userType": "Member"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.User",
      "objectType": "User",
      "objectId": "89efe8ed-d141-4151-a3e4-570a70022dff",
      "deletionTimestamp": null,
      "accountEnabled": true,
      "signInNames": [],
      "assignedLicenses": [
        {
          "disabledPlans": [],
          "skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
        }
      ],
      "assignedPlans": [
        {
          "assignedTimestamp": "2014-10-14T02:53:29Z",
          "capabilityStatus": "Enabled",
          "service": "exchange",
          "servicePlanId": "efb87545-963c-4e0d-99df-69c6916d9eb0"
        },
        {
          "assignedTimestamp": "2014-10-14T02:53:29Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "5dbe027f-2339-4123-9542-606e4d348a72"
        },
        {
          "assignedTimestamp": "2014-10-14T02:53:29Z",
          "capabilityStatus": "Enabled",
          "service": "SharePoint",
          "servicePlanId": "e95bec33-7c88-4a70-8e19-b10bd9d0c014"
        },
        {
          "assignedTimestamp": "2014-10-14T02:53:29Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftCommunicationsOnline",
          "servicePlanId": "0feaeb32-d00e-4d66-bd5a-43b5b83db82c"
        },
        {
          "assignedTimestamp": "2014-10-14T02:53:29Z",
          "capabilityStatus": "Enabled",
          "service": "MicrosoftOffice",
          "servicePlanId": "43de0ff5-c92c-492b-9116-175376d08c38"
        },
        {
          "assignedTimestamp": "2014-10-14T02:53:29Z",
          "capabilityStatus": "Enabled",
          "service": "RMSOnline",
          "servicePlanId": "bea4c11e-220a-4e6d-8eb8-8ea15d019f90"
        }
      ],
      "city": "Bellevue",
      "country": "United States",
      "creationType": null,
      "department": "Sales & Marketing",
      "dirSyncEnabled": null,
      "displayName": "Janet Schorr",
      "facsimileTelephoneNumber": null,
      "givenName": "Janet",
      "immutableId": null,
      "jobTitle": "Product Marketing Manager",
      "lastDirSyncTime": null,
      "mail": "janets@a830edad9050849NDA1.onmicrosoft.com",
      "mailNickname": "janets",
      "mobile": null,
      "onPremisesSecurityIdentifier": null,
      "otherMails": [],
      "passwordPolicies": "None",
      "passwordProfile": null,
      "physicalDeliveryOfficeName": "18/2111",
      "postalCode": "98004",
      "preferredLanguage": null,
      "provisionedPlans": [
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "exchange"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftCommunicationsOnline"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "SharePoint"
        },
        {
          "capabilityStatus": "Enabled",
          "provisioningStatus": "Success",
          "service": "MicrosoftOffice"
        }
      ],
      "provisioningErrors": [],
      "proxyAddresses": [
        "SMTP:janets@a830edad9050849NDA1.onmicrosoft.com"
      ],
      "sipProxyAddress": "janets@a830edad9050849NDA1.onmicrosoft.com",
      "state": "WA",
      "streetAddress": "205 108th Ave. NE, Suite 400",
      "surname": "Schorr",
      "telephoneNumber": "+1 425 555 0109",
      "usageLocation": "US",
      "userPrincipalName": "janets@a830edad9050849NDA1.onmicrosoft.com",
      "userType": "Member"
    }
  ]
}

Response List

Status Code Description
200 OK. Indicates success. The results are returned in the response body.

Code Samples

using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
	    static void Main()
        {
            MakeRequest();

            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }

        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            /* OAuth2 is required to access this API. For more information visit:
               https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */



		   // Specify values for the following required parameters
			queryString["api-version"] = "1.6";

			// Specify values for optional parameters, as needed
			// queryString["$filter"] = "startswith(displayName,'A')";
            // Specify values for path parameters (shown as {...})
            var uri = "https://graph.windows.net/myorganization/users?" + queryString;


            var response = await client.GetAsync(uri);

            if (response.Content != null)
            {
                var responseString = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseString);
            }
        }
    }
}
@ECHO OFF

REM OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
REM Specify values for path parameters (shown as {...}), values for query parameters
curl -v -X GET "https://graph.windows.net/myorganization/users?api-version=1.6&$filter=startswith(displayName%2c%27A%27)&"^

```Java
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample {

  public static void main(String[] args) {
	HttpClient httpclient = HttpClients.createDefault();

	try
	{
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		// Specify values for path parameters (shown as {...})
		URIBuilder builder = new URIBuilder("https://graph.windows.net/myorganization/users");
		// Specify values for the following required parameters
		builder.setParameter("api-version", "1.6");
		// Specify values for optional parameters, as needed
		// builder.setParameter("$filter", "startswith(displayName,'A')");
		URI uri = builder.build();
		HttpGet request = new HttpGet(uri);
		HttpResponse response = httpclient.execute(request);
		HttpEntity entity = response.getEntity();
		if (entity != null) {
			System.out.println(EntityUtils.toString(entity));
		}
	}
	catch (Exception e)
	{
		System.out.println(e.getMessage());
	}
  }
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
	$(function() {
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		var params = {
			// Specify values for the following required parameters
			'api-version': "1.6",
			// Specify values for optional parameters, as needed
			// $filter: "startswith(displayName,'A')",
		};
		
		$.ajax({
			// Specify values for path parameters (shown as {...})
			url: 'https://graph.windows.net/myorganization/users?' + $.param(params),
			type: 'GET',
		})
		.done(function(data) {
			alert("success");
		})
		.fail(function() {
			alert("error");
		});
	});
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
	// OAuth2 is required to access this API. For more information visit:
	// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

	// Specify values for path parameters (shown as {...})
    NSString* path = @"https://graph.windows.net/myorganization/users";
    NSArray* array = @[
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if(nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if(nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php

// This sample uses the pecl_http package. (for more information: http://pecl.php.net/package/pecl_http)
require_once 'HTTP/Request2.php';
$headers = array(
);

$query_params = array(
	// Specify values for the following required parameters
	'api-version' => '1.6',
	// Specify values for optional parameters, as needed
	//'$filter' => 'startswith(displayName,'A')',
);

$request = new Http_Request2('https://graph.windows.net/myorganization/users');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setHeader($headers);

// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

$url = $request->getUrl();
$url->setQueryVariables($query_params);

try
{
	$response = $request->send();
	
	echo $response->getBody();
}
catch (HttpException $ex)
{
	echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
	# Specify values for optional parameters, as needed
	#'$filter': 'startswith(displayName,'A')',
})

try:
	conn = httplib.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.parse.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
	# Specify values for optional parameters, as needed
	#'$filter': 'startswith(displayName,'A')',
})

try:
	conn = http.client.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://graph.windows.net/myorganization/users')

uri.query = URI.encode_www_form({
	# Specify values for the following required parameters
	'api-version' => '1.6',
	# Specify values for optional parameters, as needed
	# '$filter' => 'startswith(displayName,'A')',
})

request = Net::HTTP::Get.new(uri.request_uri)

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks



response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body

Get a user

GET https://graph.windows.net/myorganization/users/{user_id}?api-version

Parameters

Parameter Type Value Notes
URL
user_id string MeganB@M365x214355.onmicrosoft.com The user ID. Can be the object ID (GUID) or the user principal name (someuser@a830edad9050849NDA1.onmicrosoft.com) of the target user.
Query
api-version string 1.6 Specifies the version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
GET https://graph.windows.net/myorganization/users/MeganB%40M365x214355.onmicrosoft.com?api-version=1.6

Response

Status Code:200

Content-Type: application/json

"odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.User/@Element",
  "odata.type": "Microsoft.DirectoryServices.User",
  "objectType": "User",
  "objectId": "13addec1-c5ae-47f5-a1fe-202be14b1570",
  "deletionTimestamp": null,
  "accountEnabled": true,
  "signInNames": [],
  "assignedLicenses": [
    {
      "disabledPlans": [],
      "skuId": "6fd2c87f-b296-42f0-b197-1e91e994b900"
    }
  ],
  "assignedPlans": [
    {
      "assignedTimestamp": "2014-10-14T02:54:04Z",
      "capabilityStatus": "Enabled",
      "service": "exchange",
      "servicePlanId": "efb87545-963c-4e0d-99df-69c6916d9eb0"
    },
    {
      "assignedTimestamp": "2014-10-14T02:54:04Z",
      "capabilityStatus": "Enabled",
      "service": "SharePoint",
      "servicePlanId": "5dbe027f-2339-4123-9542-606e4d348a72"
    },
    {
      "assignedTimestamp": "2014-10-14T02:54:04Z",
      "capabilityStatus": "Enabled",
      "service": "SharePoint",
      "servicePlanId": "e95bec33-7c88-4a70-8e19-b10bd9d0c014"
    },
    {
      "assignedTimestamp": "2014-10-14T02:54:04Z",
      "capabilityStatus": "Enabled",
      "service": "MicrosoftCommunicationsOnline",
      "servicePlanId": "0feaeb32-d00e-4d66-bd5a-43b5b83db82c"
    },
    {
      "assignedTimestamp": "2014-10-14T02:54:04Z",
      "capabilityStatus": "Enabled",
      "service": "MicrosoftOffice",
      "servicePlanId": "43de0ff5-c92c-492b-9116-175376d08c38"
    },
    {
      "assignedTimestamp": "2014-10-14T02:54:04Z",
      "capabilityStatus": "Enabled",
      "service": "RMSOnline",
      "servicePlanId": "bea4c11e-220a-4e6d-8eb8-8ea15d019f90"
    }
  ],
  "city": "Tulsa",
  "country": "United States",
  "creationType": null,
  "department": "Sales & Marketing",
  "dirSyncEnabled": null,
  "displayName": "Garth Fort",
  "facsimileTelephoneNumber": null,
  "givenName": "Garth",
  "immutableId": null,
  "jobTitle": "Web Marketing Manager",
  "lastDirSyncTime": null,
  "mail": "garthf@a830edad9050849NDA1.onmicrosoft.com",
  "mailNickname": "garthf",
  "mobile": null,
  "onPremisesSecurityIdentifier": null,
  "otherMails": [],
  "passwordPolicies": "None",
  "passwordProfile": null,
  "physicalDeliveryOfficeName": "20/1101",
  "postalCode": "74133",
  "preferredLanguage": "en-US",
  "provisionedPlans": [
    {
      "capabilityStatus": "Enabled",
      "provisioningStatus": "Success",
      "service": "exchange"
    },
    {
      "capabilityStatus": "Enabled",
      "provisioningStatus": "Success",
      "service": "MicrosoftCommunicationsOnline"
    },
    {
      "capabilityStatus": "Enabled",
      "provisioningStatus": "Success",
      "service": "SharePoint"
    },
    {
      "capabilityStatus": "Enabled",
      "provisioningStatus": "Success",
      "service": "SharePoint"
    },
    {
      "capabilityStatus": "Enabled",
      "provisioningStatus": "Success",
      "service": "MicrosoftOffice"
    }
  ],
  "provisioningErrors": [],
  "proxyAddresses": [
    "SMTP:garthf@a830edad9050849NDA1.onmicrosoft.com"
  ],
  "sipProxyAddress": "garthf@a830edad9050849NDA1.onmicrosoft.com",
  "state": "OK",
  "streetAddress": "7633 E. 63rd Place, Suite 300",
  "surname": "Fort",
  "telephoneNumber": "+1 918 555 0101",
  "usageLocation": "US",
  "userPrincipalName": "garthf@a830edad9050849NDA1.onmicrosoft.com",
  "userType": "Member"
}

Response List

Status Code Description
200 OK. Indicates success. The user is returned in the response body.

Code Samples

using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
	    static void Main()
        {
            MakeRequest();

            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }

        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            /* OAuth2 is required to access this API. For more information visit:
               https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */



		   // Specify values for the following required parameters
			queryString["api-version"] = "1.6";
            // Specify values for path parameters (shown as {...})
            var uri = "https://graph.windows.net/myorganization/users/{user_id}?" + queryString;


            var response = await client.GetAsync(uri);

            if (response.Content != null)
            {
                var responseString = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseString);
            }
        }
    }
}
@ECHO OFF

REM OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
REM Specify values for path parameters (shown as {...}), values for query parameters
curl -v -X GET "https://graph.windows.net/myorganization/users/{user_id}?api-version=1.6&amp;"^
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample {

  public static void main(String[] args) {
	HttpClient httpclient = HttpClients.createDefault();

	try
	{
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		// Specify values for path parameters (shown as {...})
		URIBuilder builder = new URIBuilder("https://graph.windows.net/myorganization/users/{user_id}");
		// Specify values for the following required parameters
		builder.setParameter("api-version", "1.6");
		URI uri = builder.build();
		HttpGet request = new HttpGet(uri);
		HttpResponse response = httpclient.execute(request);
		HttpEntity entity = response.getEntity();
		if (entity != null) {
			System.out.println(EntityUtils.toString(entity));
		}
	}
	catch (Exception e)
	{
		System.out.println(e.getMessage());
	}
  }
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
	$(function() {
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		var params = {
			// Specify values for the following required parameters
			'api-version': "1.6",
		};
		
		$.ajax({
			// Specify values for path parameters (shown as {...})
			url: 'https://graph.windows.net/myorganization/users/{user_id}?' + $.param(params),
			type: 'GET',
		})
		.done(function(data) {
			alert("success");
		})
		.fail(function() {
			alert("error");
		});
	});
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
	// OAuth2 is required to access this API. For more information visit:
	// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

	// Specify values for path parameters (shown as {...})
    NSString* path = @"https://graph.windows.net/myorganization/users/{user_id}";
    NSArray* array = @[
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if(nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if(nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php

// This sample uses the pecl_http package. (for more information: http://pecl.php.net/package/pecl_http)
require_once 'HTTP/Request2.php';
$headers = array(
);

$query_params = array(
	// Specify values for the following required parameters
	'api-version' => '1.6',
);

$request = new Http_Request2('https://graph.windows.net/myorganization/users/{user_id}');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setHeader($headers);

// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

$url = $request->getUrl();
$url->setQueryVariables($query_params);

try
{
	$response = $request->send();
	
	echo $response->getBody();
}
catch (HttpException $ex)
{
	echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
})

try:
	conn = httplib.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users/{user_id}?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.parse.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
})

try:
	conn = http.client.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users/{user_id}?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://graph.windows.net/myorganization/users/{user_id}')

uri.query = URI.encode_www_form({
	# Specify values for the following required parameters
	'api-version' => '1.6',
})

request = Net::HTTP::Get.new(uri.request_uri)

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks



response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body

Get a user's thumbnail photo

GET https://graph.windows.net/myorganization/users/{user_id}/thumbnailPhoto?api-version
GET https://graph.windows.net/myorganization/users/MeganB%40M365x214355.onmicrosoft.com/thumbnailPhoto?api-version=1.6

Response

Status Code:200

Content-Type: image/jpeg

image data

Response List

Status Code Description
200 OK. Indicates success. The thumbnail photo is returned in the response body. Check the Content-Type header for the media type.
404 Not Found. The requested resource was not found. This can occur if the thumbnailPhoto property is not currently set for the specified user. It can also have other causes, for example, a bad domain. A code and associated message is returned with the error.

Create a user (work or school account)

POST https://graph.windows.net/myorganization/users?api-version

Parameters

Parameter Type Value Notes
Query
api-version string 1.6 The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
Body
Content-Type: application/json
{
  "accountEnabled": true,
  "displayName": "Alex Wu",
  "mailNickname": "AlexW",
  "passwordProfile": {
    "password": "Test1234",
    "forceChangePasswordNextLogin": false
  },
  "userPrincipalName": "Alex@a830edad9050849NDA1.onmicrosoft.com"
}

Response

Status Code:201

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.User/@Element",
  "odata.type": "Microsoft.DirectoryServices.User",
  "objectType": "User",
  "objectId": "84fba1e8-b942-47c9-a10e-a4bee353ce60",
  "deletionTimestamp": null,
  "accountEnabled": true,
  "signInNames": [],
  "assignedLicenses": [],
  "assignedPlans": [],
  "city": null,
  "country": null,
  "creationType": null,
  "department": null,
  "dirSyncEnabled": null,
  "displayName": "Alex Wu",
  "facsimileTelephoneNumber": null,
  "givenName": null,
  "immutableId": null,
  "jobTitle": null,
  "lastDirSyncTime": null,
  "mail": null,
  "mailNickname": "AlexW",
  "mobile": null,
  "onPremisesSecurityIdentifier": null,
  "otherMails": [],
  "passwordPolicies": null,
  "passwordProfile": null,
  "physicalDeliveryOfficeName": null,
  "postalCode": null,
  "preferredLanguage": null,
  "provisionedPlans": [],
  "provisioningErrors": [],
  "proxyAddresses": [],
  "sipProxyAddress": null,
  "state": null,
  "streetAddress": null,
  "surname": null,
  "telephoneNumber": null,
  "usageLocation": null,
  "userPrincipalName": "alex@a830edad9050849NDA1.com",
  "userType": "Member"
}

Response List

Status Code Description
201 Created. Indicates success. The new user is returned in the response body.

Create a user (local or social account)

POST https://graph.windows.net/myorganization/users?api-version

Parameters

Parameter Type Value Notes
Query
api-version string 1.6 The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
Body
Content-Type: application/json
{
  "accountEnabled": true,
  "creationType": "LocalAccount",
  "displayName": "Alex Wu",
  "passwordProfile": {
    "password": "Test1234",
    "forceChangePasswordNextLogin": false
  },
  "signInNames": [
    {
      "type": "userName",
      "value": "AlexW"
    },
    {
      "type": "emailAddress",
      "value": "AlexW@example.com"
    }
  ],
  "userIdentities": [
    {
      "issuer": "facebook.com",
      "issuerUserId": "MATxTNg5MzYyMzMyMNY1Njc="
    }
  ]
}

Response Status Code:201 Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.User/@Element",
  "odata.type": "Microsoft.DirectoryServices.User",
  "objectType": "User",
  "objectId": "84fba1e8-b942-47c9-a10e-a4bee353ce60",
  "deletionTimestamp": null,
  "accountEnabled": true,
  "signInNames": [
    {
      "type": "userName",
      "value": "AlexW"
    },
    {
      "type": "emailAddress",
      "value": "AlexW@example.com"
    }
  ],
  "userIdentities": [
    {
      "issuer": "facebook.com",
      "issuerUserId": "MATxTNg5MzYyMzMyMNY1Njc="
    }
  ],
  "assignedLicenses": [],
  "assignedPlans": [],
  "city": null,
  "country": null,
  "creationType": "LocalAccount",
  "department": null,
  "dirSyncEnabled": null,
  "displayName": "Alex Wu",
  "facsimileTelephoneNumber": null,
  "givenName": null,
  "immutableId": null,
  "jobTitle": null,
  "lastDirSyncTime": null,
  "mail": null,
  "mailNickname": "AlexW_example.com#EXT#",
  "mobile": null,
  "onPremisesSecurityIdentifier": null,
  "otherMails": [],
  "passwordPolicies": null,
  "passwordProfile": null,
  "physicalDeliveryOfficeName": null,
  "postalCode": null,
  "preferredLanguage": null,
  "provisionedPlans": [],
  "provisioningErrors": [],
  "proxyAddresses": [],
  "sipProxyAddress": null,
  "state": null,
  "streetAddress": null,
  "surname": null,
  "telephoneNumber": null,
  "usageLocation": null,
  "userPrincipalName": "AlexW_example.com#EXT#@a830edad9050849NDA1.com",
  "userType": "Member"
}

Response List

Status Code Description
201 Created. Indicates success. The new user is returned in the response body.

Update a user

PATCH https://graph.windows.net/myorganization/users/{user_id}?api-version

Parameters

Parameter Type Value Notes
URL
user_id string alexd@a830edad9050849NDA1.onmicrosoft.com The user ID. Can be the object ID (GUID) or the user principal name (someuser@a830edad9050849NDA1.onmicrosoft.com) of the target user.
Query
api-version string 1.6 The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
Body
Content-Type: application/json
{
  "department": "Sales",
  "usageLocation": "US"
}
PATCH https://graph.windows.net/myorganization/users/alexd%40a830edad9050849NDA1.onmicrosoft.com?api-version=1.6

Response Status Code:204 Content-Type: application/json

Response List

Status Code Description
204 No Content. Indicates success. No response body is returned.

Reset a user's password

PATCH https://graph.windows.net/myorganization/users/{user_id}?api-version

Parameters

Parameter Type Value Notes
URL
user_id string alexd@a830edad9050849NDA1.onmicrosoft.com The user ID. Can be the object ID (GUID) or the user principal name (someuser@a830edad9050849NDA1.onmicrosoft.com) of the target user.
Query
api-version string 1.6 The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
Body
Content-Type: application/json
{
  "passwordProfile": {
    "password": "Test123456",
    "forceChangePasswordNextLogin": false
  }
}
PATCH https://graph.windows.net/myorganization/users/alexd%40a830edad9050849NDA1.onmicrosoft.com?api-version=1.6

Response Status Code:204 Content-Type: application/json

Response List

Status Code Description
204 No Content. Indicates success. No response body is returned.

Delete a user

DELETE https://graph.windows.net/myorganization/users/{user_id}[?api-version]

Parameters

Parameter Type Value Notes
URL
user_id string marvin@a830edad9050849NDA1.onmicrosoft.com The user ID. Can be the object ID (GUID) or the user principal name (someuser@a830edad9050849NDA1.onmicrosoft.com) of the target user.
Query
api-version string 1.6 Specifies the version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
DELETE https://graph.windows.net/myorganization/users/marvin%40a830edad9050849NDA1.onmicrosoft.com?api-version=1.6

Response Status Code:204 Content-Type: application/json

Response List

Status Code Description
204 No Content. Indicates success.

Invalidate all refresh tokens for a user

POST https://graph.windows.net/myorganization/users/{user_id}/invalidateAllRefreshTokens?api-version

Parameters

Parameter Type Value Notes
URL
user_id string garthf@a830edad9050849NDA1.onmicrosoft.com The user ID. Can be the object ID (GUID) or the user principal name (someuser@a830edad9050849NDA1.onmicrosoft.com) of the target user.
Query
api-version string 1.6 Specifies the version of the Graph API to target. Required.
POST https://graph.windows.net/myorganization/users/garthf%40a830edad9050849NDA1.onmicrosoft.com/invalidateAllRefreshTokens?api-version=1.6

Response

Status Code:204

Content-Type: application/json

Response List

Status Code Description
204 No Content. Indicates success. No response body is returned.

Get a user's manager

GET https://graph.windows.net/myorganization/users/{user_id}/$links/manager?api-version

Parameters

Parameter Type Value Notes
URL
user_id string AdeleV@M365x214355.onmicrosoft.com The user ID. Can be the object ID (GUID) or the user principal name (someuser@a830edad9050849NDA1.onmicrosoft.com) of the target user.
Query api-version string 1.6 The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
GET https://graph.windows.net/myorganization/users/AdeleV%40M365x214355.onmicrosoft.com/$links/manager?api-version=1.6

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/$links/manager",
  "url": "https://graph.windows.net/myorganization/directoryObjects/fabeb27a-0481-4a80-b43e-a5c02c125874/Microsoft.WindowsAzure.ActiveDirectory.User"
}

Response List

Status Code Description
200 OK. Indicates success. A link to the user's manager is returned.
404 Not Found. The requested resource was not found. This can occur if the manager property is not currently set for the specified user. It can also have other causes, for example, a bad domain. A code and associated message is returned with the error.

Code Samples

using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
	    static void Main()
        {
            MakeRequest();

            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }

        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            /* OAuth2 is required to access this API. For more information visit:
               https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */



		   // Specify values for the following required parameters
			queryString["api-version"] = "1.6";
            // Specify values for path parameters (shown as {...})
            var uri = "https://graph.windows.net/myorganization/users/{user_id}/$links/manager?" + queryString;


            var response = await client.GetAsync(uri);

            if (response.Content != null)
            {
                var responseString = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseString);
            }
        }
    }
}
@ECHO OFF

REM OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
REM Specify values for path parameters (shown as {...}), values for query parameters
curl -v -X GET "https://graph.windows.net/myorganization/users/{user_id}/$links/manager?api-version=1.6&amp;"^
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample {

  public static void main(String[] args) {
	HttpClient httpclient = HttpClients.createDefault();

	try
	{
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		// Specify values for path parameters (shown as {...})
		URIBuilder builder = new URIBuilder("https://graph.windows.net/myorganization/users/{user_id}/$links/manager");
		// Specify values for the following required parameters
		builder.setParameter("api-version", "1.6");
		URI uri = builder.build();
		HttpGet request = new HttpGet(uri);
		HttpResponse response = httpclient.execute(request);
		HttpEntity entity = response.getEntity();
		if (entity != null) {
			System.out.println(EntityUtils.toString(entity));
		}
	}
	catch (Exception e)
	{
		System.out.println(e.getMessage());
	}
  }
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
	$(function() {
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		var params = {
			// Specify values for the following required parameters
			'api-version': "1.6",
		};
		
		$.ajax({
			// Specify values for path parameters (shown as {...})
			url: 'https://graph.windows.net/myorganization/users/{user_id}/$links/manager?' + $.param(params),
			type: 'GET',
		})
		.done(function(data) {
			alert("success");
		})
		.fail(function() {
			alert("error");
		});
	});
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
	// OAuth2 is required to access this API. For more information visit:
	// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

	// Specify values for path parameters (shown as {...})
    NSString* path = @"https://graph.windows.net/myorganization/users/{user_id}/$links/manager";
    NSArray* array = @[
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if(nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if(nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php

// This sample uses the pecl_http package. (for more information: http://pecl.php.net/package/pecl_http)
require_once 'HTTP/Request2.php';
$headers = array(
);

$query_params = array(
	// Specify values for the following required parameters
	'api-version' => '1.6',
);

$request = new Http_Request2('https://graph.windows.net/myorganization/users/{user_id}/$links/manager');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setHeader($headers);

// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

$url = $request->getUrl();
$url->setQueryVariables($query_params);

try
{
	$response = $request->send();
	
	echo $response->getBody();
}
catch (HttpException $ex)
{
	echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
})

try:
	conn = httplib.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users/{user_id}/$links/manager?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.parse.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
})

try:
	conn = http.client.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users/{user_id}/$links/manager?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://graph.windows.net/myorganization/users/{user_id}/$links/manager')

uri.query = URI.encode_www_form({
	# Specify values for the following required parameters
	'api-version' => '1.6',
})

request = Net::HTTP::Get.new(uri.request_uri)

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks



response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body

Assign a user's manager

PUT https://graph.windows.net/myorganization/users/{user_id}/$links/manager?api-version

Parameters

Parameter Type Value Notes
URL
user_id string alexd@a830edad9050849NDA1.onmicrosoft.com The user ID. Can be the object ID (GUID) or the user principal name (someuser@a830edad9050849NDA1.onmicrosoft.com) of the target user.
Query
api-version string 1.6 The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
Body
Content-Type: application/json
{
  "url": "https://graph.windows.net/contoso.onmicrosoft.com/directoryObjects/fabeb27a-0481-4a80-b43e-a5c02c125874"
}
PUT https://graph.windows.net/myorganization/users/alexd%40a830edad9050849NDA1.onmicrosoft.com/$links/manager?api-version=1.6

Response

Status Code:204

Content-Type: application/json

Response List

Status Code Description
204 No Content. Indicates success. No response body is returned.

Get a user's direct reports

GET https://graph.windows.net/myorganization/users/{user_id}/$links/directReports?api-version

Parameters

Parameter Type Value Notes
URL
user_id string MiriamG@M365x214355.onmicrosoft.com The user ID. Can be the object ID (GUID) or the user principal name (someuser@a830edad9050849NDA1.onmicrosoft.com) of the target user.
Query api-version string 1.6 The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
GET https://graph.windows.net/myorganization/users/MiriamG%40M365x214355.onmicrosoft.com/$links/directReports?api-version=1.6
{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/$links/directReports",
  "value": [
    {
      "url": "https://graph.windows.net/myorganization/directoryObjects/84fba1e8-b942-47c9-a10e-a4bee353ce60/Microsoft.DirectoryServices.User"
    }
  ]
}

Response List

Status Code Description
200 OK. Indicates success. One or more direct reports are returned.

Code Samples

using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
	    static void Main()
        {
            MakeRequest();

            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }

        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            /* OAuth2 is required to access this API. For more information visit:
               https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */



		   // Specify values for the following required parameters
			queryString["api-version"] = "1.6";
            // Specify values for path parameters (shown as {...})
            var uri = "https://graph.windows.net/myorganization/users/{user_id}/$links/directReports?" + queryString;


            var response = await client.GetAsync(uri);

            if (response.Content != null)
            {
                var responseString = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseString);
            }
        }
    }
}
@ECHO OFF

REM OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
REM Specify values for path parameters (shown as {...}), values for query parameters
curl -v -X GET "https://graph.windows.net/myorganization/users/{user_id}/$links/directReports?api-version=1.6&amp;"^
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample {

  public static void main(String[] args) {
	HttpClient httpclient = HttpClients.createDefault();

	try
	{
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		// Specify values for path parameters (shown as {...})
		URIBuilder builder = new URIBuilder("https://graph.windows.net/myorganization/users/{user_id}/$links/directReports");
		// Specify values for the following required parameters
		builder.setParameter("api-version", "1.6");
		URI uri = builder.build();
		HttpGet request = new HttpGet(uri);
		HttpResponse response = httpclient.execute(request);
		HttpEntity entity = response.getEntity();
		if (entity != null) {
			System.out.println(EntityUtils.toString(entity));
		}
	}
	catch (Exception e)
	{
		System.out.println(e.getMessage());
	}
  }
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
	$(function() {
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		var params = {
			// Specify values for the following required parameters
			'api-version': "1.6",
		};
		
		$.ajax({
			// Specify values for path parameters (shown as {...})
			url: 'https://graph.windows.net/myorganization/users/{user_id}/$links/directReports?' + $.param(params),
			type: 'GET',
		})
		.done(function(data) {
			alert("success");
		})
		.fail(function() {
			alert("error");
		});
	});
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
	// OAuth2 is required to access this API. For more information visit:
	// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

	// Specify values for path parameters (shown as {...})
    NSString* path = @"https://graph.windows.net/myorganization/users/{user_id}/$links/directReports";
    NSArray* array = @[
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if(nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if(nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php

// This sample uses the pecl_http package. (for more information: http://pecl.php.net/package/pecl_http)
require_once 'HTTP/Request2.php';
$headers = array(
);

$query_params = array(
	// Specify values for the following required parameters
	'api-version' => '1.6',
);

$request = new Http_Request2('https://graph.windows.net/myorganization/users/{user_id}/$links/directReports');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setHeader($headers);

// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

$url = $request->getUrl();
$url->setQueryVariables($query_params);

try
{
	$response = $request->send();
	
	echo $response->getBody();
}
catch (HttpException $ex)
{
	echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
})

try:
	conn = httplib.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users/{user_id}/$links/directReports?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.parse.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
})

try:
	conn = http.client.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users/{user_id}/$links/directReports?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://graph.windows.net/myorganization/users/{user_id}/$links/directReports')

uri.query = URI.encode_www_form({
	# Specify values for the following required parameters
	'api-version' => '1.6',
})

request = Net::HTTP::Get.new(uri.request_uri)

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks



response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body

Get a user's group and directory role memberships

GET https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf?api-version

Parameters

Parameter Type Value Notes
URL
user_id string MiriamG@M365x214355.onmicrosoft.com The user ID. Can be the object ID (GUID) or the user principal name (someuser@a830edad9050849NDA1.onmicrosoft.com) of the target user.
Query
api-version string 1.6 The version of the Graph API to target. Beginning with version 1.5, the api-version string is represented in major.minor format. Prior releases were represented as date strings: '2013-11-08' and '2013-04-05'. Required.
GET https://graph.windows.net/myorganization/users/MiriamG%40M365x214355.onmicrosoft.com/$links/memberOf?api-version=1.6

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/$links/memberOf",
  "value": [
    {
      "url": "https://graph.windows.net/myorganization/directoryObjects/12345678-b942-47c9-a10e-a4bee353ce60/Microsoft.DirectoryServices.Group"
    }
  ]
}

Response List

Status Code Description
200 OK. Indicates success. One or more groups and/or directory roles are returned.

Code Samples

using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
	    static void Main()
        {
            MakeRequest();

            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }

        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            /* OAuth2 is required to access this API. For more information visit:
               https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks */



		   // Specify values for the following required parameters
			queryString["api-version"] = "1.6";
            // Specify values for path parameters (shown as {...})
            var uri = "https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf?" + queryString;


            var response = await client.GetAsync(uri);

            if (response.Content != null)
            {
                var responseString = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseString);
            }
        }
    }
}
@ECHO OFF

REM OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks
REM Specify values for path parameters (shown as {...}), values for query parameters
curl -v -X GET "https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf?api-version=1.6&amp;"^
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample {

  public static void main(String[] args) {
	HttpClient httpclient = HttpClients.createDefault();

	try
	{
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		// Specify values for path parameters (shown as {...})
		URIBuilder builder = new URIBuilder("https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf");
		// Specify values for the following required parameters
		builder.setParameter("api-version", "1.6");
		URI uri = builder.build();
		HttpGet request = new HttpGet(uri);
		HttpResponse response = httpclient.execute(request);
		HttpEntity entity = response.getEntity();
		if (entity != null) {
			System.out.println(EntityUtils.toString(entity));
		}
	}
	catch (Exception e)
	{
		System.out.println(e.getMessage());
	}
  }
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
	$(function() {
		// OAuth2 is required to access this API. For more information visit:
		// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

		var params = {
			// Specify values for the following required parameters
			'api-version': "1.6",
		};
		
		$.ajax({
			// Specify values for path parameters (shown as {...})
			url: 'https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf?' + $.param(params),
			type: 'GET',
		})
		.done(function(data) {
			alert("success");
		})
		.fail(function() {
			alert("error");
		});
	});
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
	// OAuth2 is required to access this API. For more information visit:
	// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

	// Specify values for path parameters (shown as {...})
    NSString* path = @"https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf";
    NSArray* array = @[
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];
    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
    if(nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if(nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];
    return 0;
}
<?php

// This sample uses the pecl_http package. (for more information: http://pecl.php.net/package/pecl_http)
require_once 'HTTP/Request2.php';
$headers = array(
);

$query_params = array(
	// Specify values for the following required parameters
	'api-version' => '1.6',
);

$request = new Http_Request2('https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setHeader($headers);

// OAuth2 is required to access this API. For more information visit:
// https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

$url = $request->getUrl();
$url->setQueryVariables($query_params);

try
{
	$response = $request->send();
	
	echo $response->getBody();
}
catch (HttpException $ex)
{
	echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
})

try:
	conn = httplib.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users/{user_id}/$links/memberOf?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks

headers = {
}

params = urllib.parse.urlencode({
	# Specify values for the following required parameters
	'api-version': '1.6',
})

try:
	conn = http.client.HTTPSConnection('graph.windows.net')
	# Specify values for path parameters (shown as {...}) and request body if needed
	conn.request("GET", "/myorganization/users/{user_id}/$links/memberOf?%s" % params, "", headers)
	response = conn.getresponse()
	data = response.read()
	print(data)
	conn.close()
except Exception as e:
	print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf')

uri.query = URI.encode_www_form({
	# Specify values for the following required parameters
	'api-version' => '1.6',
})

request = Net::HTTP::Get.new(uri.request_uri)

# OAuth2 is required to access this API. For more information visit: https://msdn.microsoft.com/en-us/office/office365/howto/common-app-authentication-tasks



response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body