Listar membros transitivos de grupo
Artigo
07/18/2022
13 minutos para o fim da leitura
3 colaboradores
Neste artigo
Namespace: microsoft.graph
Obtenha uma lista dos membros do grupo. Um grupo pode ter usuários, dispositivos, contatos organizacionais e outros grupos como membros. Essa operação é transitiva e retorna uma lista simples de todos os membros aninhados.
Permissões
Uma das seguintes permissões é obrigatória para chamar esta API. Para saber mais, incluindo como escolher permissões, confira Permissões .
Tipo de permissão
Permissões (da com menos para a com mais privilégios)
Delegado (conta corporativa ou de estudante)
GroupMember.Read.All, Group.Read.All, Group.Member.ReadWrite.All, Group.ReadWrite.All, Directory.Read.All
Delegado (conta pessoal da Microsoft)
Sem suporte.
Aplicativo
GroupMember.Read.All, Group.Read.All, Group.Member.ReadWrite.All, Group.ReadWrite.All, Directory.Read.All
Nota: Para listar os membros de um grupo de associação oculto, a permissão Member.Read.Hidden é necessária.
Quando um aplicativo consulta uma relação que retorna uma coleção de tipo directoryObject, caso não tenha permissão para ler determinado tipo (como dispositivo), os membros desse tipo são retornados, mas com informações limitadas. Com esse comportamento, os aplicativos podem solicitar as permissões menos privilegiadas de que precisam, em vez de depender do conjunto de Diretório. * permissões. Para obter mais detalhes, confira Informações limitadas retornadas para objetos membro inacessíveis .
Solicitação HTTP
GET /groups/{id}/transitiveMembers
Parâmetros de consulta opcionais
Este método dá suporte a Parâmetros de consulta OData para ajudar a personalizar a resposta, incluindo $search, $count, e $filter. Você pode usar $search nas propriedades displayName e descrição . Quando itens são adicionados ou atualizados para este recurso, eles são indexados especialmente para uso com os $count e $search parâmetros de consulta. Pode haver um pequeno atraso entre quando um item é adicionado ou atualizado e quando está disponível no índice.
Para filtrar os resultados no tipo OData, como microsoft.graph.user ou microsoft.graph.group, você deve usar os parâmetros de consulta avançados . Ou seja, o cabeçalho ConsistencyLevel definido como e eventual a cadeia de caracteres $count=true de consulta.
Nome
Descrição
Autorização
{token} de portador. Obrigatório.
ConsistencyLevel
eventualmente. Este cabeçalho e $count são necessários quando se utiliza $search, $filter, $orderby ou os parâmetros de consulta de conversão OData. Ele usa um índice que pode não estar atualizado com as alterações recentes no objeto.
Corpo da solicitação
Não forneça um corpo de solicitação para esse método.
Resposta
Se bem-sucedido, este método retorna um código de resposta 200 OK e uma coleção de objetos directoryObject no corpo da resposta.
Exemplos
Exemplo 1: Obter a associação transitiva de um grupo
Solicitação
Este é um exemplo de solicitação.
GET https://graph.microsoft.com/v1.0/groups/{id}/transitiveMembers
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var transitiveMembers = await graphClient.Groups["{group-id}"].TransitiveMembers
.Request()
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var transitiveMembers = await graphClient.Groups["{group-id}"].TransitiveMembers
.Request()
.GetAsync();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
const options = {
authProvider,
};
const client = Client.init(options);
let transitiveMembers = await client.api('/groups/{id}/transitiveMembers')
.get();
const options = {
authProvider,
};
const client = Client.init(options);
let transitiveMembers = await client.api('/groups/{id}/transitiveMembers')
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/transitiveMembers"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphDirectoryObject *directoryObject = [[MSGraphDirectoryObject alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/transitiveMembers"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphDirectoryObject *directoryObject = [[MSGraphDirectoryObject alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DirectoryObjectCollectionWithReferencesPage transitiveMembers = graphClient.groups("{id}").transitiveMembers()
.buildRequest()
.get();
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
DirectoryObjectCollectionWithReferencesPage transitiveMembers = graphClient.groups("{id}").transitiveMembers()
.buildRequest()
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).TransitiveMembers().Get()
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).TransitiveMembers().Get()
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Import-Module Microsoft.Graph.Groups
Get-MgGroupTransitiveMember -GroupId $groupId
Import-Module Microsoft.Graph.Groups
Get-MgGroupTransitiveMember -GroupId $groupId
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Resposta
Este é um exemplo de resposta.
Observação : o objeto de resposta mostrado aqui pode ser encurtado com fins de legibilidade.
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"@odata.type": "#microsoft.graph.user",
"id": "11111111-2222-3333-4444-555555555555",
"mail": "group1@contoso.com"
}
]
}
Exemplo 2: Obter apenas uma contagem de associação transitiva
Solicitação
Este é um exemplo de solicitação.
GET https://graph.microsoft.com/v1.0/groups/{id}/transitiveMembers/$count
ConsistencyLevel: eventual
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var int32 = await graphClient.Groups["{group-id}"].TransitiveMembers.$count
.Request()
.Header("ConsistencyLevel","eventual")
.GetAsync();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
const options = {
authProvider,
};
const client = Client.init(options);
let int32 = await client.api('/groups/{id}/transitiveMembers/$count')
.header('ConsistencyLevel','eventual')
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/transitiveMembers/$count"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphInt32 *int32 = [[MSGraphInt32 alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
int int32 = graphClient.groups("{id}").transitiveMembers().count()
.buildRequest( requestOptions )
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Resposta
Este é um exemplo de resposta.
Observação: o objeto de resposta mostrado aqui pode ser encurtado para legibilidade.
HTTP/1.1 200 OK
Content-type: text/plain
893
Exemplo 3: Usar a conversão OData microsoft.graph.group para obter apenas membros que são grupos
Solicitação
Este é um exemplo de solicitação.
GET https://graph.microsoft.com/v1.0/groups/{id}/transitivemembers/microsoft.graph.group?$count=true
ConsistencyLevel: eventual
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var group = await graphClient.Groups["{group-id}"].TransitiveMembers
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var group = await graphClient.Groups["{group-id}"].TransitiveMembers
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.GetAsync();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
const options = {
authProvider,
};
const client = Client.init(options);
let group = await client.api('/groups/{id}/transitivemembers/microsoft.graph.group')
.header('ConsistencyLevel','eventual')
.get();
const options = {
authProvider,
};
const client = Client.init(options);
let group = await client.api('/groups/{id}/transitivemembers/microsoft.graph.group')
.header('ConsistencyLevel','eventual')
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/transitivemembers/microsoft.graph.group?$count=true"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/transitivemembers/microsoft.graph.group?$count=true"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphGroup *group = [[MSGraphGroup alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
GroupCollectionPage group = graphClient.groups("{id}").transitiveMembers().microsoft.graph.group()
.buildRequest( requestOptions )
.get();
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
GroupCollectionPage group = graphClient.groups("{id}").transitiveMembers().microsoft.graph.group()
.buildRequest( requestOptions )
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.GroupRequestBuilderGetQueryParameters{
Count: true,
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.GroupRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).TransitiveMembers().Group(group-id).GetWithRequestConfigurationAndResponseHandler(options, nil)
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.GroupRequestBuilderGetQueryParameters{
Count: true,
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.GroupRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).TransitiveMembers().Group(group-id).GetWithRequestConfigurationAndResponseHandler(options, nil)
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Resposta
Este é um exemplo de resposta.
Observação: o objeto de resposta mostrado aqui pode ser encurtado para legibilidade.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups",
"@odata.count": 2,
"value": [
{
"@odata.id": "https://graph.microsoft.com/v2/927c6607-8060-4f4a-a5f8-34964ac78d70/directoryObjects/4d0ef681-e88f-42a3-a2db-e6bf1e249e10/Microsoft.DirectoryServices.Group",
"id": "4d0ef681-e88f-42a3-a2db-e6bf1e249e10",
"organizationId": "927c6607-8060-4f4a-a5f8-34964ac78d70",
"description": null,
"displayName": "Executives",
"groupTypes": [],
"mail": "Executives@contoso.com",
"mailEnabled": true,
"mailNickname": "Executives",
},
{
"@odata.id": "https://graph.microsoft.com/v2/927c6607-8060-4f4a-a5f8-34964ac78d70/directoryObjects/d9fb0c47-c783-40a1-bce1-53b52ada51fc/Microsoft.DirectoryServices.Group",
"id": "d9fb0c47-c783-40a1-bce1-53b52ada51fc",
"organizationId": "927c6607-8060-4f4a-a5f8-34964ac78d70",
"displayName": "Project Falcon",
"groupTypes": [],
"mail": "Falcon@contoso.com",
"mailEnabled": true,
"mailNickname": "Falcon",
}
]
}
Exemplo 4: usar conversão E $search OData para obter associação em grupos com nomes de exibição que contêm as letras "camada", incluindo uma contagem de objetos retornados
Solicitação
Este é um exemplo de solicitação.
GET https://graph.microsoft.com/v1.0/groups/{id}/transitiveMembers/microsoft.graph.user?$count=true&$orderBy=displayName&$search="displayName:tier"&$select=displayName,id
ConsistencyLevel: eventual
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var user = await graphClient.Groups["{group-id}"].TransitiveMembers
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Search("displayName:tier")
.Select("displayName,id")
.OrderBy("displayName")
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var user = await graphClient.Groups["{group-id}"].TransitiveMembers
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Search("displayName:tier")
.Select("displayName,id")
.OrderBy("displayName")
.GetAsync();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
const options = {
authProvider,
};
const client = Client.init(options);
let user = await client.api('/groups/{id}/transitiveMembers/microsoft.graph.user')
.header('ConsistencyLevel','eventual')
.search('displayName:tier')
.select('displayName,id')
.orderby('displayName')
.get();
const options = {
authProvider,
};
const client = Client.init(options);
let user = await client.api('/groups/{id}/transitiveMembers/microsoft.graph.user')
.header('ConsistencyLevel','eventual')
.search('displayName:tier')
.select('displayName,id')
.orderby('displayName')
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/transitiveMembers/microsoft.graph.user?$count=true&$orderBy=displayName&$search=%22displayName:tier%22&$select=displayName,id"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphUser *user = [[MSGraphUser alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/transitiveMembers/microsoft.graph.user?$count=true&$orderBy=displayName&$search=%22displayName:tier%22&$select=displayName,id"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphUser *user = [[MSGraphUser alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
requestOptions.add(new QueryOption("$search", "displayName:tier"));
UserCollectionPage user = graphClient.groups("{id}").transitiveMembers().microsoft.graph.user()
.buildRequest( requestOptions )
.select("displayName,id")
.orderBy("displayName")
.get();
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
requestOptions.add(new QueryOption("$search", "displayName:tier"));
UserCollectionPage user = graphClient.groups("{id}").transitiveMembers().microsoft.graph.user()
.buildRequest( requestOptions )
.select("displayName,id")
.orderBy("displayName")
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.UserRequestBuilderGetQueryParameters{
Count: true,
OrderBy: "displayName",
Search: "%22displayName:tier%22",
Select: "displayName,id",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.UserRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).TransitiveMembers().User(group-id).GetWithRequestConfigurationAndResponseHandler(options, nil)
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.UserRequestBuilderGetQueryParameters{
Count: true,
OrderBy: "displayName",
Search: "%22displayName:tier%22",
Select: "displayName,id",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.UserRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).TransitiveMembers().User(group-id).GetWithRequestConfigurationAndResponseHandler(options, nil)
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Resposta
Este é um exemplo de resposta.
Observação: o objeto de resposta mostrado aqui pode ser encurtado para legibilidade.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users(displayName,id)",
"@odata.count":7,
"value":[
{
"displayName":"Joseph Price",
"id":"11111111-2222-3333-4444-555555555555"
}
]
}
Exemplo 5: Usar conversão e conversão de OData $filter para obter associação de usuário em grupos com um nome de exibição que começa com "A", incluindo uma contagem de objetos retornados
Solicitação
Este é um exemplo de solicitação.
GET https://graph.microsoft.com/v1.0/groups/{id}/transitiveMembers/microsoft.graph.user?$count=true&$orderBy=displayName&$filter=startswith(displayName, 'a')
ConsistencyLevel: eventual
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var user = await graphClient.Groups["{group-id}"].TransitiveMembers
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Filter("startswith(displayName, 'a')")
.OrderBy("displayName")
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var contacts = await graphClient.Contacts
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Filter("startswith(displayName,'A')")
.OrderBy("displayName")
.Top(1)
.GetAsync();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
const options = {
authProvider,
};
const client = Client.init(options);
let user = await client.api('/groups/{id}/transitiveMembers/microsoft.graph.user')
.header('ConsistencyLevel','eventual')
.filter('startswith(displayName, \'a\')')
.orderby('displayName')
.get();
const options = {
authProvider,
};
const client = Client.init(options);
let devices = await client.api('/devices')
.header('ConsistencyLevel','eventual')
.filter('startswith(displayName, \'a\')')
.orderby('displayName')
.top(1)
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/transitiveMembers/microsoft.graph.user?$count=true&$orderBy=displayName&$filter=startswith(displayName,%20'a')"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphUser *user = [[MSGraphUser alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/devices?$filter=startswith(displayName,%20'a')&$count=true&$top=1&$orderby=displayName"]]];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setValue:@"eventual" forHTTPHeaderField:@"ConsistencyLevel"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphDevice *device = [[MSGraphDevice alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
UserCollectionPage user = graphClient.groups("{id}").transitiveMembers().microsoft.graph.user()
.buildRequest( requestOptions )
.filter("startswith(displayName, 'a')")
.orderBy("displayName")
.get();
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Option> requestOptions = new LinkedList<Option>();
requestOptions.add(new HeaderOption("ConsistencyLevel", "eventual"));
DeviceCollectionPage devices = graphClient.devices()
.buildRequest( requestOptions )
.filter("startswith(displayName, 'a')")
.orderBy("displayName")
.top(1)
.get();
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.UserRequestBuilderGetQueryParameters{
Count: true,
OrderBy: "displayName",
Filter: "startswith(displayName,%20'a')",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.UserRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
Headers: headers,
}
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).TransitiveMembers().User(group-id).GetWithRequestConfigurationAndResponseHandler(options, nil)
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.ContactsRequestBuilderGetQueryParameters{
Filter: "startswith(displayName,'A')",
Count: true,
Top: 1,
Orderby: "displayName",
}
headers := map[string]string{
"ConsistencyLevel": "eventual"
}
options := &msgraphsdk.ContactsRequestBuilderGetOptions{
Q: requestParameters,
H: headers,
}
result, err := graphClient.Contacts().Get(options)
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Import-Module Microsoft.Graph.Identity.DirectoryManagement
Get-MgContact -Filter "startswith(displayName,'A')" -CountVariable CountVar -Top 1 -Sort "displayName" -ConsistencyLevel eventual
Para obter detalhes sobre como adicionar o SDK ao seu projeto e criar uma instância authProvider , consulte a documentação do SDK .
Resposta
Este é um exemplo de resposta.
Observação: o objeto de resposta mostrado aqui pode ser encurtado para legibilidade.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users",
"@odata.count":76,
"value":[
{
"displayName":"AAD Contoso Users",
"mail":"AADContoso_Users@contoso.com"
}
]
}