共用方式為


使用者的作業 | Graph API 參考

**適用於︰**Graph API | Azure Active Directory

本主題討論如何使用 Azure Active Directory (AD) Graph API 對使用者執行作業。 使用 Azure AD Graph API,您可以建立、讀取、更新及刪除使用者。 您也可以查詢及修改使用者與其他目錄實體的關聯性。 例如,您可以指派使用者的管理員,查詢使用者的直屬員工,管理指派給使用者的群組成員資格、應用程式角色和裝置,以及執行更多工作。

Graph API 是 OData 3.0 相容的 REST API,可讓您以程式設計方式存取 Azure Active Directory 中的目錄物件,例如使用者、群組、組織連絡人和應用程式。

重要

您也可以透過 Microsoft Graph 取得 Azure AD Graph API 功能,這個統一 API 同時也包含如 Outlook、OneDrive、OneNote、Planner 和 Office Graph 等其他 Microsoft 服務 API,讓您可以使用單一的存取權杖透過單一端點存取所有 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 版本,而且其 Authorization 標頭中攜帶取自 Azure AD 的有效存取權杖。 如需使用 Graph API 建立要求以及接收回應的詳細資訊,請參閱[Operations Overview]。

您可以根據目標設為租用戶中的所有使用者集合、個別使用者還是特定使用者的導覽屬性,透過不同的方式指定資源路徑。

  • /users 將目標設為使用者資源集合。 您可以使用此資源路徑讀取租用戶中的所有使用者或篩選過的使用者清單,或在租用戶中建立一或多個新的使用者。
  • /users/{user_id} 將目標設為租用戶中的個別使用者。 您可以指定 user_id 作為目標使用者的物件識別碼 (GUID) 或使用者主體名稱 (UPN)。 您可以使用此資源路徑取得使用者的已宣告屬性、修改使用者的已宣告屬性,或刪除使用者。
  • /users/{user_id}/{property} 將目標設為使用者的指定導覽屬性。 您可以使用它來傳回所指定使用者的目標導覽屬性所參考的一或多個物件。 注意:這種形式的定址僅供讀取。
  • /users/{user_id}/$links/{property} 將目標設為使用者的指定導覽屬性。 您可以使用這種定址形式來讀取和修改導覽屬性。 讀取時,此屬性所參考的物件會傳回為回應主體中的一或多個連結。 寫入時,物件會指定為要求主體中的一或多個連結。

例如,下列要求會傳回所指定使用者管理員的連結︰

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"      
    } 
}

取得使用者

取得指定的使用者。 您可以使用物件識別碼 (GUID) 或使用者主體名稱 (UPN) 來識別目標使用者。

成功時,傳回所指定使用者的 [User] 物件;否則,回應主體會包含錯誤詳細資料。 如需錯誤的詳細資訊,請參閱[Error Codes and Error Handling]。

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

取得使用者的縮圖相片

透過 thumbnailPhoto 屬性取得指定使用者的縮圖相片。 您可以使用物件識別碼 (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 布林值 若已啟用帳戶,則為 true;否則為 false
displayName 字串 使用者顯示於通訊錄中的名稱。
immutableId 字串 如果您使用使用者的 userPrincipalName (UPN) 屬性的同盟網域,只有在建立新的使用者帳戶時才必須指定。
mailNickname 字串 使用者的郵件別名。
passwordProfile [PasswordProfile] 使用者的密碼設定檔。
userPrincipalName 字串 使用者主體名稱 (someuser@contoso.com)。 使用者主體名稱必須包含租用戶的其中一個已驗證網域。

成功時,傳回新建立的 [User];否則,回應主體會包含錯誤詳細資料。 如需錯誤的詳細資訊,請參閱[Error Codes and Error Handling]。

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

建立使用者 (本機帳戶)

從 Graph API 1.6 版開始,支援為 Azure Active Directory B2C 租用戶建立本機帳戶使用者。 不同於與工作或學校帳戶相關聯的使用者需要使用包含租用戶之其中一個已驗證網域的電子郵件地址進行登入,本機帳戶使用者支援使用應用程式特定的認證進行登入;例如,第三方電子郵件地址或應用程式特定的使用者名稱。 如需 Azure Active Directory B2C 的詳細資訊,請參閱 Azure Active Directory B2C 文件

要求主體包含要建立之本機帳戶使用者的屬性。 您至少必須指定本機帳戶使用者所需的屬性。 如下表所示,這些屬性與針對工作或學校帳戶指定的屬性稍有不同。 針對本機帳戶使用者,您必須指定 creationType 屬性來指出使用者是本機帳戶,也必須指定 signInNames 屬性來傳遞使用者的登入名稱。 除了必要的屬性,您還可以選擇性地指定 [User] 實體上任何其他可寫入的屬性;不過,這通常僅限於應用程式定義的擴充功能屬性,以及 [User] 實體上的可用屬性子集。 您無法將授權或訂用帳戶指派給本機帳戶使用者。

下表顯示建立本機帳戶使用者時所需的屬性。

必要參數 類型 說明
accountEnabled 布林值 若已啟用帳戶,則為 true;否則為 false
creationType 字串 必須設定為 "LocalAccount" 來建立本機帳戶使用者。 注意:在搶鮮版 (Beta) 中指定為 "NameCoexistence"。
displayName 字串 使用者顯示於通訊錄中的名稱。
passwordProfile [PasswordProfile] 使用者的密碼設定檔。
signInNames collection([SignInName]) 指定使用者登入名稱的一或多個 [SignInName] 記錄。 每個登入名稱在公司/租用戶中必須是唯一的。 注意︰已從搶鮮版 (Beta) 中的 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