Vorgänge für Verzeichnisrollen | Graph-API-Referenz

Gilt für: Graph-API | Azure Active Directory

In diesem Artikel wird erläutert, wie mit der Azure AD (Active Directory) Graph-API Vorgänge für Azure AD-Verzeichnisrollen ausgeführt werden. Verzeichnisrollen (DirectoryRole) enthalten bestimmte Gruppen von Rechten im Verzeichnis. Azure AD erteilt den Benutzern und Dienstprinzipalen, die Mitglieder einer Verzeichnisrolle sind, die Rechte, die dieser Rolle zugeordnet sind. Azure AD-Verzeichnisrollen werden auch als Administratorrollen bezeichnet. Weitere Informationen zu Verzeichnisrollen bzw. Administratorrollen finden Sie unter Zuweisen von Administratorrollen in Azure Active Directory.

Mit der Graph-API können Sie die Eigenschaften von Verzeichnisrollen lesen, Mitglieder einer Verzeichnisrolle abfragen und Mitglieder in einer Verzeichnisrolle hinzufügen und löschen. Verzeichnisrollen können Benutzer und Dienstprinzipale als Mitglieder enthalten. Das Hinzufügen von Gruppen zu Verzeichnisrollen wird derzeit nicht unterstützt.

In den Versionen vor Version 1.5 waren standardmäßig alle Verzeichnisrollen im Mandanten vorhanden. Ab Version 1.5 ist nur die Verzeichnisrolle „Unternehmensadministratoren“ standardmäßig vorhanden. Um auf Mitglieder in einer anderen Verzeichnisrolle zuzugreifen und sie zuzuweisen, müssen Sie diese zunächst mithilfe der entsprechenden Verzeichnisrollenvorlage (DirectoryRoleTemplate) aktivieren. Weitere Informationen finden Sie unter Aktivieren einer Verzeichnisrolle.

Bei der Graph-API handelt es sich um eine mit OData 3.0 kompatible REST-API, die einen programmgesteuerten Zugriff auf Verzeichnisobjekte in Azure Active Directory (Azure AD) ermöglicht, z.B. auf Benutzer, Gruppen, Organisationskontakte und Anwendungen.

Wichtig

Die Funktionen der Azure AD Graph-API sind auch über Microsoft Graph verfügbar. Dies ist eine einheitliche API, die auch APIs von anderen Microsoft-Diensten wie Outlook, OneDrive, OneNote, Planner und Office Graph enthält. Auf alle wird über einen einzigen Endpunkt mit einem einzigen Zugriffstoken zugegriffen.

Ausführen von REST-Vorgängen für Verzeichnisrollen

Zum Ausführen von Vorgängen für Verzeichnisrollen mit der Graph-API senden Sie mit einer unterstützten Methode (GET, POST, PATCH, PUT oder DELETE) HTTP-Anforderungen an einen Endpunkt für die directoryRoles-Ressourcensammlung, eine bestimmte Verzeichnisrolle, eine Navigationseigenschaft einer Verzeichnisrolle oder eine Funktion oder Aktion, die für eine Verzeichnisrolle aufgerufen werden kann.

URLs für Graph-API-Anforderungen weisen das folgende Format auf:

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

Wichtig

An die Graph-API gesendete Anforderungen müssen wohlgeformt sein, an einen gültigen Endpunkt und eine gültige Version der Graph-API gerichtet sein und im Authorization-Header ein gültiges Zugriffstoken von Azure AD enthalten. Ausführlichere Informationen zum Erstellen von Anforderungen und Empfangen von Antworten mit der Graph-API finden Sie unter Operations Overview.

Der von Ihnen angegebene {resource_path} hängt davon ab, ob das Ziel die Sammlung aller Verzeichnisrollen im Mandanten, eine einzelne Verzeichnisrolle oder eine Navigationseigenschaft einer bestimmten Verzeichnisrolle ist.

  • /directoryRoles gibt den Pfad zur directoryRoles-Ressourcensammlung an. Sie können diesen Ressourcenpfad zum Lesen aller Verzeichnisrollen im Mandanten und ab Version 1.5 zum Aktivieren einer Verzeichnisrolle im Mandanten verwenden.
  • /directoryRoleTemplates gibt den Pfad zur directoryRoleTemplates-Ressourcensammlung an. Sie können diesen Ressourcenpfad zum Lesen sämtlicher im Mandanten verfügbaren Verzeichnisrollenvorlagen verwenden. Ab Version 1.5 verwenden Sie zum Aktivieren von Verzeichnisrollen im Mandanten Verzeichnisrollenvorlagen.
  • /directoryRoles/{object_id} gibt den Pfad zu einer einzelnen Verzeichnisrolle im Mandanten an. Sie geben die Zielrolle mit ihrer Objekt-ID (GUID) an. Sie können mit diesem Ressourcenpfad die deklarierten Eigenschaften einer angegebenen Verzeichnisrolle abrufen.
  • /directoryRoles/{object_id}/members gibt den Pfad zur members-Navigationseigenschaft einer Verzeichnisrolle an. Sie können mit ihr die Benutzer und Dienstprinzipale zurückgeben, die Mitglieder der angegebenen Verzeichnisrolle sind. Hinweis: Diese Form der Adressierung ist nur für Lesevorgänge verfügbar.
  • /directoryRoles/{object_id}/$links/members gibt den Pfad zur members-Navigationseigenschaft einer Verzeichnisrolle an. Sie können diese Form der Adressierung für Lesevorgänge und zum Ändern der Mitglieder der Rolle verwenden. Bei Lesevorgängen werden Benutzer und Dienstprinzipale, auf die von der Eigenschaft verwiesen wird, als einer oder mehrere Links im Antworttext zurückgegeben. Bei Schreibvorgängen werden die Benutzer und Dienstprinzipale als einer oder mehrere Links im Anforderungstext angegeben.

Beispielsweise gibt die folgende Anforderung eine Sammlung von Links zu den Mitgliedern der angegebenen Verzeichnisrolle zurück:

GET https://graph.windows.net/myorganization/directoryRoles/ffffffff-ffff-ffff-ffff-ffffffffffff/$links/members?api-version=1.6

Grundlegende Vorgänge für Verzeichnisrollen

Sie können die folgenden grundlegenden Vorgänge für Verzeichnisrollen und Verzeichnisrollenvorlagen ausführen.

  • Lesen der Eigenschaften aller Verzeichnisrollen oder einer einzelnen Rolle
  • Lesen der Eigenschaften aller Verzeichnisrollenvorlagen oder einer einzelnen Vorlage (Version 1.5 und höher)
  • Aktivieren einer Verzeichnisrolle mithilfe einer POST-Anforderung (Version 1.5 und höher)

In den folgenden Themen wird die Vorgehensweise beschrieben.


Abrufen von Verzeichnisrollen

Ruft die Sammlung der Verzeichnisrollen ab, die im Mandanten aktiviert sind. (In den Versionen vor Version 1.5 wurden alle Verzeichnisrollen standardmäßig aktiviert.)

Bei Erfolg wird die Sammlung der aktivierten DirectoryRole-Objekte zurückgegeben. Andernfalls enthält der Antworttext Fehlerinformationen. Weitere Informationen zu Fehlern finden Sie unter Error Codes and Error Handling.

GET https://graph.windows.net/myorganization/directoryRoles?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.

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.DirectoryRole",
  "value": [
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRole",
      "objectType": "Role",
      "objectId": "02618ff0-e643-450d-b9b2-2f812364eb2c",
      "deletionTimestamp": null,
      "description": "Helpdesk Administrator has access to perform common helpdesk related tasks.",
      "displayName": "Helpdesk Administrator",
      "isSystem": true,
      "roleDisabled": false,
      "roleTemplateId": "729827e3-9c14-49f7-bb1b-9608f156bbb8"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRole",
      "objectType": "Role",
      "objectId": "044ca859-dc72-47cb-b466-7f6e78398979",
      "deletionTimestamp": null,
      "description": "Allows access read tasks and a subset of write tasks in the directory.",
      "displayName": "Directory Writers",
      "isSystem": true,
      "roleDisabled": false,
      "roleTemplateId": "9360feb5-f418-4baa-8175-e2a00bac4301"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRole",
      "objectType": "Role",
      "objectId": "44261f4c-b686-44c1-8997-310171ed4ca8",
      "deletionTimestamp": null,
      "description": "Allows access to various read only tasks in the directory. ",
      "displayName": "Directory Readers",
      "isSystem": true,
      "roleDisabled": false,
      "roleTemplateId": "88d8e3e3-8f55-4a1e-953a-9b9898b8876b"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRole",
      "objectType": "Role",
      "objectId": "cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8",
      "deletionTimestamp": null,
      "description": "Company Administrator role has full access to perform any operation in the company scope.",
      "displayName": "Company Administrator",
      "isSystem": true,
      "roleDisabled": false,
      "roleTemplateId": "62e90394-69f5-4237-9190-012177145e10"
    }
  ]
}

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 path parameters (shown as {...})
            var uri = "https://graph.windows.net/myorganization/directoryRoles?" + 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/directoryRoles?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/myorganization/directoryRoles");
		// 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/directoryRoles?' + $.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/directoryRoles";
    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/directoryRoles');
$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/directoryRoles?%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/directoryRoles?%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/directoryRoles')

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

Abrufen einer Verzeichnisrolle

Ruft eine angegebene Verzeichnisrolle ab. Geben Sie die Verzeichnisrolle anhand ihrer Objekt-ID (GUID) an.

Bei Erfolg wird das DirectoryRole-Objekt für die angegebene Verzeichnisrolle zurückgegeben. Andernfalls enthält der Antworttext Fehlerinformationen. Weitere Informationen zu Fehlern finden Sie unter Error Codes and Error Handling.

GET https://graph.windows.net/myorganization/directoryRoles/{object_id}?api-version

Parameters

Parameter Type Value Notes
URL
object_id string cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8 The object ID (GUID) of the target directory role.
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/directoryRoles/cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8?api-version=1.6

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.DirectoryRole/@Element",
  "odata.type": "Microsoft.DirectoryServices.DirectoryRole",
  "objectType": "Role",
  "objectId": "cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8",
  "deletionTimestamp": null,
  "description": "Company Administrator role has full access to perform any operation in the company scope.",
  "displayName": "Company Administrator",
  "isSystem": true,
  "roleDisabled": false,
  "roleTemplateId": "62e90394-69f5-4237-9190-012177145e10"
}

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 path parameters (shown as {...})
            var uri = "https://graph.windows.net/myorganization/directoryRoles/{object_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/directoryRoles/{object_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/directoryRoles/{object_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/directoryRoles/{object_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/directoryRoles/{object_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/directoryRoles/{object_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/directoryRoles/{object_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/directoryRoles/{object_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/directoryRoles/{object_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

Abrufen von Verzeichnisrollenvorlagen

Ruft die Sammlung der Verzeichnisrollenvorlagen ab, die im Mandanten verfügbar sind. Ab Version 1.5 werden zum Aktivieren von Verzeichnisrollen Verzeichnisrollenvorlagen verwendet. In Versionen vor Version 1.5 nicht verfügbar.

Bei Erfolg wird die Sammlung der DirectoryRoleTemplate-Objekte für den Mandanten zurückgegeben. Andernfalls enthält der Antworttext Fehlerinformationen. Weitere Informationen zu Fehlern finden Sie unter Error Codes and Error Handling.

GET https://graph.windows.net/myorganization/directoryRoleTemplates?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.

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.DirectoryRoleTemplate",
  "value": [
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "729827e3-9c14-49f7-bb1b-9608f156bbb8",
      "deletionTimestamp": null,
      "description": "Helpdesk Administrator has access to perform common helpdesk related tasks.",
      "displayName": "Helpdesk Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "f023fd81-a637-4b56-95fd-791ac0226033",
      "deletionTimestamp": null,
      "description": "Service Support Administrator has access to perform common support tasks.",
      "displayName": "Service Support Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "b0f54661-2d74-4c50-afa3-1ec803f12efe",
      "deletionTimestamp": null,
      "description": "Billing Administrator has access to perform common billing related tasks.",
      "displayName": "Billing Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "b5468a13-3945-4a40-b0b1-5d78c2676bbf",
      "deletionTimestamp": null,
      "description": "Allows access and management of users mailboxes.",
      "displayName": "Mailbox Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "4ba39ca4-527c-499a-b93d-d9b492c50246",
      "deletionTimestamp": null,
      "description": "Allows ability to perform tier1 support tasks.",
      "displayName": "Partner Tier1 Support"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "e00e864a-17c5-4a4b-9c06-f5b95a8d5bd8",
      "deletionTimestamp": null,
      "description": "Allows ability to perform tier2 support tasks.",
      "displayName": "Partner Tier2 Support"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "88d8e3e3-8f55-4a1e-953a-9b9898b8876b",
      "deletionTimestamp": null,
      "description": "Allows access to various read only tasks in the directory. ",
      "displayName": "Directory Readers"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "29232cdf-9323-42fd-ade2-1d097af3e4de",
      "deletionTimestamp": null,
      "description": "Exchange Service Administrator.",
      "displayName": "Exchange Service Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "75941009-915a-4869-abe7-691bff18279e",
      "deletionTimestamp": null,
      "description": "Lync Service Administrator.",
      "displayName": "Lync Service Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "fe930be7-5e62-47db-91af-98c3a49a38b1",
      "deletionTimestamp": null,
      "description": "User Account Administrator has access to perform common user management related tasks.",
      "displayName": "User Account Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "9360feb5-f418-4baa-8175-e2a00bac4301",
      "deletionTimestamp": null,
      "description": "Allows access read tasks and a subset of write tasks in the directory.",
      "displayName": "Directory Writers"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "62e90394-69f5-4237-9190-012177145e10",
      "deletionTimestamp": null,
      "description": "Company Administrator role has full access to perform any operation in the company scope.",
      "displayName": "Company Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "a0b1b346-4d3e-4e8b-98f8-753987be4970",
      "deletionTimestamp": null,
      "description": "Every user is implicitly considered to be a member of the User Role.",
      "displayName": "User"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "d65e02d2-0214-4674-8e5d-766fb330e2c0",
      "deletionTimestamp": null,
      "description": "Allows creation of new email verified users.",
      "displayName": "Email Verified User Creator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "eb1d8c34-acf5-460d-8424-c1f1a6fbdb85",
      "deletionTimestamp": null,
      "description": "Allows access manage AdHoc license.",
      "displayName": "AdHoc License Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "f28a1f50-f6e7-4571-818b-6a12f2af6b6c",
      "deletionTimestamp": null,
      "description": "SharePoint Service Administrator.",
      "displayName": "SharePoint Service Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "d405c6df-0af8-4e3b-95e4-4d06e542189e",
      "deletionTimestamp": null,
      "description": "Device Users",
      "displayName": "Device Users"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "9f06204d-73c1-4d4c-880a-6edb90606fd8",
      "deletionTimestamp": null,
      "description": "Device Administrators",
      "displayName": "Device Administrators"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "9c094953-4995-41c8-84c8-3ebb9b32c93f",
      "deletionTimestamp": null,
      "description": "Device Join",
      "displayName": "Device Join"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "c34f683f-4d5a-4403-affd-6615e00e3a7f",
      "deletionTimestamp": null,
      "description": "Workplace Device Join",
      "displayName": "Workplace Device Join"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "17315797-102d-40b4-93e0-432062caca18",
      "deletionTimestamp": null,
      "description": "Compliance administrator.",
      "displayName": "Compliance Administrator"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "d29b2b05-8046-44ba-8758-1e26182fcf32",
      "deletionTimestamp": null,
      "description": "Directory Synchronization Accounts",
      "displayName": "Directory Synchronization Accounts"
    },
    {
      "odata.type": "Microsoft.DirectoryServices.DirectoryRoleTemplate",
      "objectType": "RoleTemplate",
      "objectId": "2b499bcd-da44-4968-8aec-78e1674fa64d",
      "deletionTimestamp": null,
      "description": "Allows access to read and edit device properties. ",
      "displayName": "Device Managers"
    }
  ]
}

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 path parameters (shown as {...})
            var uri = "https://graph.windows.net/myorganization/directoryRoleTemplates?" + 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/directoryRoleTemplates?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/directoryRoleTemplates");
		// 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/directoryRoleTemplates?' + $.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/directoryRoleTemplates";
    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/directoryRoleTemplates');
$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/directoryRoleTemplates?%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/directoryRoleTemplates?%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/directoryRoleTemplates')

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

Aktivieren einer Verzeichnisrolle

Aktiviert einer Verzeichnisrolle im Mandanten. Nur in Version 1.5 und höher verfügbar. Der Anforderungstext enthält die Objekt-ID der Verzeichnisrollenvorlage für die Verzeichnisrolle, die Sie aktivieren möchten.

Hinweis: In den Versionen vor Version 1.5 waren standardmäßig alle Verzeichnisrollen im Mandanten vorhanden. Ab Version 1.5 ist nur die Verzeichnisrolle „Unternehmensadministratoren“ standardmäßig vorhanden. Um auf Mitglieder in einer anderen Verzeichnisrolle zuzugreifen und sie zuzuweisen, müssen Sie diese zunächst mit der entsprechenden Verzeichnisrollenvorlage (DirectoryRoleTemplate) aktivieren.

In der folgenden Tabelle werden die Eigenschaften beschrieben, die erforderlich sind, wenn Sie eine Verzeichnisrolle aktivieren.

Erforderlicher Parameter Typ Beschreibung
roleTemplateId string Die objectId der DirectoryRoleTemplate, auf der die Rolle basiert.

Bei Erfolg wird die neu erstellte DirectoryRole zurückgegeben. Andernfalls enthält der Antworttext Fehlerinformationen. Weitere Informationen zu Fehlern finden Sie unter Error Codes and Error Handling.

POST https://graph.windows.net/myorganization/directoryRoles?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 ----- ----- ------
{
  "roleTemplateId": "88d8e3e3-8f55-4a1e-953a-9b9898b8876b"
}

Response

Status Code:201

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/Microsoft.DirectoryServices.DirectoryRole/@Element",
  "odata.type": "Microsoft.DirectoryServices.DirectoryRole",
  "objectType": "Role",
  "objectId": "ebabdd59-04ba-46f0-bd7f-bef08fe8fa9b",
  "deletionTimestamp": null,
  "description": "Allows access to various read only tasks in the directory. ",
  "displayName": "Directory Readers",
  "isSystem": true,
  "roleDisabled": false,
  "roleTemplateId": "88d8e3e3-8f55-4a1e-953a-9b9898b8876b"
}

Response List

Status Code Description
201 Created. Indicates success. The newly activated directory role is returned in the response body.

Vorgänge für Navigationseigenschaften von Verzeichnisrollen

Navigationseigenschaften stellen Beziehungen zwischen einer Instanz einer Entität und anderen Objekten im Verzeichnis dar. Verzeichnisrollen machen nur eine einzelne Navigationseigenschaft verfügbar, und zwar die members-Eigenschaft. Diese Eigenschaft enthält Benutzer und Dienstprinzipale, die der Verzeichnisrolle hinzugefügt wurden. Sie können durch Angeben der members-Eigenschaft Mitglieder im Verzeichnis lesen (GET), hinzufügen (POST) und löschen (DELETE).

Abrufen von Mitgliedern einer Verzeichnisrolle

Ruft die Mitglieder einer Verzeichnisrolle aus der members-Navigationseigenschaft ab.

Bei Erfolg wird eine Sammlung von Links zu den Users und ServicePrincipals zurückgegeben, die Mitglieder der Verzeichnisrolle sind. Andernfalls enthält der Antworttext Fehlerinformationen. Weitere Informationen zu Fehlern finden Sie unter Error Codes and Error Handling.

Hinweis: Sie können das $links-Segment aus der URL entfernen, wenn statt Links DirectoryObjects für die Benutzer und Dienstprinzipale zurückgegeben werden sollen.

GET https://graph.windows.net/myorganization/directoryRoles/{object_id}/$links/members?api-version

Parameters

Parameter Type Value Notes
URL
object_id string cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8 The object ID (GUID) of the target directory role
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/directoryRoles/cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8/$links/members?api-version=1.6

Response

Status Code:200

Content-Type: application/json

{
  "odata.metadata": "https://graph.windows.net/myorganization/$metadata#directoryObjects/$links/members",
  "value": [
    {
      "url": "https://graph.windows.net/myorganization/directoryObjects/f19096bf-a58c-46ba-9ffd-0344f1daecf8/Microsoft.DirectoryServices.User"
    }
  ]
}

Response List

Status Code Description
200 OK. Indicates success. A collection of links to the directory role members is 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/directoryRoles/{object_id}/$links/members?" + 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/directoryRoles/{object_id}/$links/members?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/directoryRoles/{object_id}/$links/members");
		// 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/directoryRoles/{object_id}/$links/members?' + $.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/directoryRoles/{object_id}/$links/members";
    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/directoryRoles/{object_id}/$links/members');
$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/directoryRoles/{object_id}/$links/members?%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/directoryRoles/{object_id}/$links/members?%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/directoryRoles/{object_id}/$links/members')

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

Hinzufügen von Verzeichnisrollenmitgliedern

Fügt einer Verzeichnisrolle über die members-Navigationseigenschaft ein oder mehrere Mitglieder hinzu. Sie können Benutzer oder Dienstprinzipale hinzufügen. Der Anforderungstext enthält einen oder mehrere Links zu den Users und ServicePrincipals, die hinzugefügt werden sollen.

Bei Erfolg wird kein Antworttext zurückgegeben. Andernfalls enthält der Antworttext Fehlerinformationen. Weitere Informationen zu Fehlern finden Sie unter Error Codes and Error Handling.

POST https://graph.windows.net/myorganization/directoryRoles/{object_id}/$links/members?api-version

Parameters

Parameter Type Value Notes
URL
object_id string cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8 The object ID (GUID) of the target directory role.
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/myorganization/directoryObjects/3eb6055a-baeb-44d4-a1ea-2fee86d8891b"
}
POST https://graph.windows.net/myorganization/directoryRoles/cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8/$links/members?api-version=1.6

Response

Status Code:204

Content-Type: application/json

none

Response List

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

Löschen eines Verzeichnisrollenmitglieds

Löscht über die members-Navigationseigenschaft ein angegebenes Mitglied aus einer Verzeichnisrolle. Geben Sie im letzten URL-Segment die Objekt-ID des zu löschenden User oder ServicePrincipal an.

Bei Erfolg wird kein Antworttext zurückgegeben. Andernfalls enthält der Antworttext Fehlerinformationen. Weitere Informationen zu Fehlern finden Sie unter Error Codes and Error Handling.

DELETE https://graph.windows.net/myorganization/directoryRoles/{object_id}/$links/members/{member_id}?api-version

Parameters

Parameter Type Value Notes
URL
object_id string cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8 The object ID (GUID) of the target directory role.
member_id string 3eb6055a-baeb-44d4-a1ea-2fee86d8891b The object ID (GUID) of the member to be removed. Can be a user or a service principal.
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.
DELETE https://graph.windows.net/myorganization/directoryRoles/cb5d9ae9-6e2c-41a0-9194-0d4aef426ba8/$links/members/3eb6055a-baeb-44d4-a1ea-2fee86d8891b?api-version=1.6

Response

Status Code:204

Content-Type: application/json

none

Response List

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

Funktionen und Aktionen für Verzeichnisrollen

Sie können für Verzeichnisrollen jede der folgenden Funktionen aufrufen.

Abrufen aller Gruppen- und Verzeichnisrollenmitgliedschaften (transitiv)

Sie können die getMemberObjects-Funktion aufrufen, um alle Gruppen und Verzeichnisrollen zurückzugeben, in denen ein Benutzer, ein Kontakt, eine Gruppe oder ein Dienstprinzipal Mitglied ist. Die Überprüfung ist für Gruppen transitiv (Verzeichnisrollen können nicht Gruppen oder andere Verzeichnisrollen als Mitglieder enthalten).

Abrufen von Objekten aus einer Liste von Objekt-IDs

Rufen Sie die getObjectsByObjectIds-Funktion für den Verzeichnisdienst auf, um die Verzeichnisobjekte zurückzugeben, die in einer Liste von Objekt-IDs angegeben sind. Sie können mit dem optionalen types-Parameter auch angeben, welche Ressourcensammlungen (Benutzer, Gruppen usw.) durchsucht werden sollen. Beispielsweise können Sie mit dieser Funktion die Verzeichnisrollen in der Liste der Objekt-IDs suchen, die von der oben genannten getMemberObjects-Funktion zurückgegeben werden.


Weitere Ressourcen

  • Weitere Informationen zu den unterstützten Features, Funktionen und Vorschaufeatures der Graph-API finden Sie in Graph-API-Konzepte.