サインインしているユーザーに対する操作 | Graph API リファレンス

適用対象: Graph API | Azure Active Directory

このトピックでは、me エイリアスを使用して 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 操作の実行

me エイリアスを使用すると、サインインしているユーザーを対象にすることができます。 Graph API でサインインしているユーザーに対する操作を実行するには、サインインしているユーザー、ユーザーのナビゲーション プロパティ、またはユーザーに対して呼び出すことができる関数またはアクションを操作の対象にするための me エイリアスの使用をサポートしているメソッド (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]」を参照してください。

me エイリアスを使用すると、サインインしているユーザーを対象にすることができます。 このエイリアスは、要求 URL の {tenant id} および {resource path} セグメントを置き換えます。 me エイリアスを使用して Graph API に要求を送信すると、要求にアタッチされているベアラー トークンからテナントとユーザーが派生されます。 たとえば、GET 要求を https://graph.windows.net/me?api-version=1.6 に送信すると、サインインしているユーザーのユーザー オブジェクトが返されます。

サインインしているユーザーまたはそのユーザーのナビゲーション プロパティのどちらを対象とするかにより、指定する URL が異なります。

  • me は、サインインしているユーザーを対象にします。 このリソース パスを使用して、ユーザーの宣言されたプロパティを取得および変更できます。
  • me/{nav_property} は、サインインしているユーザーの指定されたナビゲーション プロパティが対象となります。 これを使用して、ユーザーの対象ナビゲーション プロパティによって参照されるオブジェクトを取得できます。 : この形式のアドレス指定は読み取りの場合にのみ使用できます。
  • me/$links/{nav_property} は、サインインしているユーザーの指定されたナビゲーション プロパティが対象となります。 この形式のアドレス指定を使用すると、ナビゲーション プロパティの読み取りと変更の両方を行うことができます。 読み取り時には、プロパティによって参照されるオブジェクトは、応答本文で 1 つ以上のリンクとして返されます。 書き込み時には、オブジェクトは、要求本文で 1 つ以上のリンクとして指定されます。

たとえば、次の要求は、サインインしているユーザーのマネージャーへのリンクを返します。

GET https://graph.windows.net/me/$links/manager?api-version=1.6

サインインしているユーザーに対する基本操作

me エイリアスを使用すると、サインインしているユーザーを読み取り、その宣言されたプロパティを更新できます。 以下ではその方法について説明します。


サインインしているユーザーの取得

サインインしているユーザーを取得します。

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

{
    "api":  "MeOps",
    "operation":    "get me",
     "showComponents": {
        "codeGenerator":    "true",
        "tryFeature": "true"      
    } 
}

サインインしているユーザーの更新

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

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

{
    "api":  "MeOps",
    "operation":    "update me"
}

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

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


サインインしているユーザーのマネージャー (オブジェクト) の取得

サインインしているユーザーのマネージャー (オブジェクト) を、manager ナビゲーション プロパティから取得します。

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

ユーザーにマネージャーが割り当てられていない場合は、404 Not Found が返されます。

{
    "api":  "MeOps",
    "operation":    "get my manager object",
     "showComponents": {
        "codeGenerator":    "true",
        "tryFeature": "true"      
    } 
}

サインインしているユーザーのマネージャー (リンク) の取得

サインインしているユーザーのマネージャーへのリンクを、manager ナビゲーション プロパティから取得します。

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

ユーザーにマネージャーが割り当てられていない場合は、404 Not Found が返されます。

{
    "api":  "MeOps",
    "operation":    "get my manager link",
     "showComponents": {
        "codeGenerator":    "true",
        "tryFeature": "true"      
    } 
}

サインインしているユーザーのマネージャーの更新

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

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

{
    "api":  "MeOps",
    "operation":    "set my manager"
}

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

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


サインインしているユーザーに対する関数とアクション

me エイリアスを使用すると、サインインしているユーザーに対して次の関数またはアクションを呼び出すことができます。

ライセンスの割り当てまたは削除

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

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

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

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

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

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

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

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

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


その他のリソース

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

Basic operations on the signed-in user

GET https://graph.windows.net/me?api-version
Parameter Type Value Notes
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.

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 signed-in 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/me?" + 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/me?api-version=1.6&"^
// 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/me");
		// 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/me?' + $.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/me";
    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/me');
$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", "/me?%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", "/me?%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/me')

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 the signed-in user's manager (object)

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

GET https://graph.windows.net/me/$links/manager[?api-version]

Parameters |Parameter| Type|Value|Notes| |---------|-----|-----|------| |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.|

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 signed-in user's manager is returned.| |404| Not Found. The requested resource was not found. This could be due to a bad domain, a bad user ID, or can occur if the manager property is not currently set for the specified user.|

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 optional parameters, as needed
			// queryString["api-version"] = "1.6";
            // Specify values for path parameters (shown as {...})
            var uri = "https://graph.windows.net/me/$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/me/$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/me/$links/manager");
		// Specify values for optional parameters, as needed
		// 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 optional parameters, as needed
			// api-version: "1.6",
		};
		
		$.ajax({
			// Specify values for path parameters (shown as {...})
			url: 'https://graph.windows.net/me/$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/me/$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 optional parameters, as needed
	//'api-version' => '1.6',
);

$request = new Http_Request2('https://graph.windows.net/me/$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 optional parameters, as needed
	#'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", "/me/$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 optional parameters, as needed
	#'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", "/me/$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/me/$links/manager')

uri.query = URI.encode_www_form({
	# Specify values for optional parameters, as needed
	# '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

Update the signed-in user's manager

PUT https://graph.windows.net/me/$links/manager?api-version

Parameters |Parameter |Type| Value| Notes| |-----------|----|------|--------| |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.| |Body| |Content-Type: application/json|

{
  "url": "https://graph.windows.net/contoso.onmicrosoft.com/directoryObjects/fabeb27a-0481-4a80-b43e-a5c02c125874"
}

Response

Status Code:204

Content-Type: application/json

Response List |Status Code |Description| |-----------|-----------| |204| No Content. Indicates success. No response body is returned.| |404 |Not Found. The requested resource was not found. For exmaple, this could be due to a bad domain.|