Operazioni sui ruoli della directory | Informazioni di riferimento sull'API Graph
Si applica a: API Graph | Azure Active Directory
Questo argomento descrive come eseguire operazioni sui ruoli di directory di Azure AD usando l'API Graph di Azure Active Directory (Azure AD). I ruoli della directory (DirectoryRole) eseguono set di diritti specifici all'interno della directory. Azure AD concede alle entità utenti e servizio che sono membri di un ruolo della directory i diritti associati a tale ruolo. I ruoli della directory di Azure AD sono noti anche come ruoli di amministratore. Per altre informazioni sui ruoli della directory (di amministratore), vedere Assegnazione dei ruoli di amministratore in Azure AD.
Con l'API Graph è possibile leggere le proprietà dei ruoli della directory, eseguire query sui membri di un ruolo della directory e aggiungere ed eliminare membri a e da un ruolo della directory. I membri dei ruoli della directory potrebbero essere le entità utenti e servizio. L'aggiunta di gruppi ai ruoli della directory non è attualmente supportata.
Nelle versioni precedenti alla 1.5, tutti i ruoli della directory sono presenti nel tenant per impostazione predefinita. Nella versione 1.5 e successive, per impostazione predefinita è presente solo il ruolo della directory Amministratore società. Per accedere e assegnare membri a un altro ruolo della directory, è necessario prima attivarla usando il modello di ruolo della directory corrispondente (DirectoryRoleTemplate). Per altre informazioni, vedere Attiva un ruolo della directory.
L'API Graph è un'API REST conforme alla specifica OData 3.0 che fornisce accesso a livello di codice agli oggetti directory in Azure Active Directory, ad esempio utenti, gruppi, contatti aziendali e applicazioni.
Importante
La funzionalità API Graph di Azure AD è anche disponibile tramite Microsoft Graph, un'API unificata che include le API di altri servizi Microsoft, come Outlook, OneDrive, OneNote, Planner e Office Graph, a cui si può accedere mediante un unico endpoint con un singolo token di accesso.
Esecuzione di operazioni REST sui ruoli della directory
Per eseguire operazioni sui ruoli della directory con l'API Graph, si inviano richieste HTTP con un metodo supportato (GET, POST, PATCH, PUT o DELETE) a un endpoint che fa riferimento alla raccolta di risorse directoryRoles, a un ruolo della directory specifico, a una proprietà di navigazione di un ruolo della directory oppure a una funzione o azione che può essere chiamata su un ruolo della directory.
Le richieste dell'API Graph usano l'URL di base seguente:
https://graph.windows.net/{tenant_id}/{resource_path}?{api_version}[odata_query_parameters]
Importante
Le richieste inviate all'API Graph devono presentare il formato corretto, specificare come destinazione un endpoint e una versione dell'API Graph corretti e includere nell'intestazione Authorization
un token di accesso valido ottenuto da Azure AD. Per informazioni dettagliate sulla creazione di richieste e la ricezione di risposte con l'API Graph, vedere Operations Overview.
Il percorso {resource_path}
specificato sarà diverso a seconda della destinazione dell'operazione, ad esempio la raccolta di tutti i ruoli della directory nel tenant, un singolo ruolo della directory o una proprietà di navigazione di un ruolo della directory specifico.
/directoryRoles
indica che la destinazione è la raccolta di risorse directoryRoles. È possibile usare questo percorso della risorsa per leggere tutti i ruoli della directory nel tenant e, nella versione 1.5 e successive, per attivare un ruolo della directory nel tenant./directoryRoleTemplates
indica che la destinazione è la raccolta di risorse directoryRoleTemplates. È possibile usare questo percorso della risorsa per leggere tutti modelli di ruolo della directory disponibili nel tenant. Nella versione 1.5 e successive, usare i modelli di ruolo della directory per attivare un ruolo della directory nel tenant./directoryRoles/{object_id}
indica che la destinazione è un singolo ruolo della directory nel tenant. Il ruolo di destinazione viene identificato con il relativo ID oggetto (GUID). È possibile usare il percorso della risorsa per ottenere le proprietà dichiarate di un ruolo della directory specificato./directoryRoles/{object_id}/members
indica che la destinazione è la proprietà di navigazione members di un ruolo della directory. È possibile usarlo per restituire le entità utenti e servizio che sono membri del ruolo della directory specificato. Nota: questo modello di definizione del percorso è disponibile solo per le operazioni di lettura./directoryRoles/{object_id}/$links/members
indica che la destinazione è la proprietà di navigazione members di un ruolo della directory. È possibile usare questo modello di definizione del percorso per le operazioni di lettura e di modifica del ruolo. Per le operazioni di lettura, le entità utenti e servizio a cui fa riferimento la proprietà vengono restituite come uno o più collegamenti nel corpo della risposta. Per le operazioni di scrittura, le entità utenti e servizio sono specificate come uno o più collegamenti nel corpo della richiesta.
La richiesta seguente, ad esempio, restituisce una raccolta di collegamenti ai membri del ruolo della directory specificato:
GET https://graph.windows.net/myorganization/directoryRoles/ffffffff-ffff-ffff-ffff-ffffffffffff/$links/members?api-version=1.6
Operazioni di base sui ruoli della directory
È possibile eseguire le operazioni di base seguenti sui ruoli della directory e sui modelli di ruolo della directory.
- Leggere le proprietà di tutti i ruoli della directory o di un singolo ruolo.
- Leggere le proprietà di tutti i modelli di ruolo della directory o di un singolo modello (versione 1.5 e successive).
- Attivare un ruolo della directory usando una richiesta POST (versione 1.5 e successive).
Gli argomenti seguenti illustrano come fare.
Ottieni ruoli della directory
Ottiene la raccolta di ruoli della directory che vengono attivati nel tenant. (per le versioni precedenti alla 1.5, tutti i ruoli della directory sono attivati per impostazione predefinita).
Se l'operazione riesce, restituisce la raccolta di oggetti DirectoryRole che sono attivati; in caso contrario, il corpo della risposta contiene i dettagli dell'errore. Per altre informazioni sugli errori, vedere 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
Ottieni un ruolo della directory
Ottiene un ruolo della directory specificato. Specificare il ruolo della directory usando l'ID oggetto (GUID) corrispondente.
Se l'operazione riesce, restituisce l'oggetto DirectoryRole per il ruolo specificato; in caso contrario, il corpo della risposta contiene i dettagli dell'errore. Per altre informazioni sugli errori, vedere 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&"^
// 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
Ottieni modelli di ruoli della directory
Ottiene la raccolta di modelli di ruoli della directory che sono disponibili nel tenant. Nella versione 1.5 e successive, usare i modelli di ruolo della directory per attivare i ruoli della directory. Non disponibile nelle versioni precedenti alla 1.5.
Se l'operazione riesce, restituisce la raccolta di oggetti DirectoryRoleTemplate per il tenant; in caso contrario, il corpo della risposta contiene i dettagli dell'errore. Per altre informazioni sugli errori, vedere 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&"^
// 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
Attiva un ruolo della directory
Attiva un ruolo della directory nel tenant. Disponibile solo nella versione 1.5 e successive. Il corpo della richiesta contiene l'ID oggetto del modello di ruolo della directory per il ruolo della directory che si vuole attivare.
Nota: nelle versioni precedenti alla 1.5, tutti i ruoli della directory sono presenti nel tenant per impostazione predefinita. Nella versione 1.5 e successive, per impostazione predefinita è presente solo il ruolo della directory Amministratore società. Per accedere e assegnare membri a un altro ruolo della directory, è necessario prima attivarla con il modello di ruolo della directory corrispondente (DirectoryRoleTemplate).
La tabella seguente mostra le proprietà necessarie per l'attivazione di un ruolo della directory.
Parametro obbligatorio | Tipo | Descrizione |
---|---|---|
roleTemplateId | stringa | objectId dell'oggetto DirectoryRoleTemplate su cui si basa il ruolo. |
Se l'operazione riesce, restituisce l'oggetto DirectoryRole appena creato; in caso contrario, il corpo della risposta contiene i dettagli dell'errore. Per altre informazioni sugli errori, vedere 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. |
Operazioni sulle proprietà di navigazione del ruolo della directory
Le proprietà di navigazione rappresentano le relazioni tra un'istanza di un'entità e altri oggetti nella directory. I ruoli della directory espongono solo una singola proprietà di navigazione, la proprietà members. Questa proprietà contiene le entità utenti e servizio che sono stati aggiunte al ruolo della directory. È possibile leggere (GET), aggiungere (POST) ed eliminare (DELETE) membri dal ruolo della directory indicando come destinazione la proprietà members.
Ottieni i membri di un ruolo della directory
Ottiene i membri del ruolo della directory dalla proprietà di navigazione members.
Se l'operazione riesce, viene restituita una raccolta di collegamenti agli oggetti User e ServicePrincipal che sono membri del ruolo della directory; in caso contrario il corpo della risposta contiene i dettagli dell'errore. Per altre informazioni sugli errori, vedere Error Codes and Error Handling.
Nota: è possibile rimuovere il segmento "$links" dall'URL per restituire gli oggetti DirectoryObject per le entità utenti e servizio anziché i collegamenti.
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&"^
// 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
Aggiungi i membri del ruolo della directory
Aggiunge uno o più membri a un ruolo della directory usando la proprietà di navigazione members. È possibile aggiungere entità utenti o servizio. Il corpo della richiesta contiene uno o più collegamenti agli oggetti User e ServicePrincipal da aggiungere.
Se l'operazione riesce, non viene restituito alcun corpo della risposta; in caso contrario, il corpo della risposta contiene i dettagli dell'errore. Per altre informazioni sugli errori, vedere 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. |
Elimina i membri del ruolo della directory
Elimina un membro specificato da un ruolo della directory usando la proprietà di navigazione members. Specificare l'ID oggetto dell'oggetto User o ServicePrincipal da eliminare nel segmento terminale dell'URL.
Se l'operazione riesce, non viene restituito alcun corpo della risposta; in caso contrario, il corpo della risposta contiene i dettagli dell'errore. Per altre informazioni sugli errori, vedere 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. |
Funzioni e azioni sui ruoli della directory
È possibile chiamare tutte le funzioni seguenti per i ruoli della directory.
Ottieni le appartenenze a gruppi e ruoli della directory (transitiva)
Chiamare la funzione getMemberObjects per ottenere tutti i gruppi e i ruoli della directory di cui un utente, un contatto, un gruppo o un'entità servizio è membro. La verifica è transitiva per i gruppi (i ruoli della directory non possono avere gruppi o altri ruoli della directory come membri).
Ottieni oggetti da un elenco di ID oggetto
Chiamare la funzione getObjectsByObjectIds nel servizio directory per restituire gli oggetti directory specificati in un elenco di ID oggetto. È anche possibile indicare le raccolte di risorse, ad esempio utenti, gruppi e così via, da cercare specificando il parametro types facoltativo. Ad esempio, è possibile usare questa funzione per trovare i ruoli della directory nell'elenco di ID oggetto restituiti dalla funzione getMemberObjects precedente.
Risorse aggiuntive
- Per altre informazioni sulle funzionalità supportate e le funzionalità di anteprima dell'API Graph, vedere Concetti relativi all'API Graph