繁体   English   中英

Microsoft.Graph SDK 获取“组”类型组的成员

[英]Microsoft.Graph SDK Get members of the group of type 'Group'

我正在尝试仅获取“组”类型的组的成员。 下面是代码:


var _graphServiceClient = new GraphServiceClient(CreateAuthProviderFromSecret(creds));

var applicationsInGroup = await _graphServiceClient.Groups[objectId.ToString()].Members.Group.GetAsync();


public static IAuthenticationProvider CreateAuthProviderFromSecret(GraphCredentials creds)
{
    var confidentialClientApplication = ConfidentialClientApplicationBuilder
    .Create(creds.ClientId)
    .WithTenantId(creds.TenantId)
    .WithClientSecret(creds.ClientSecret)
    .Build();

    return new ClientCredentialProvider(confidentialClientApplication);
}

运行时,我看到此错误:

图片

我错过了什么?

using Azure.Identity;
using Graph.Community;
using Microsoft.Graph;

var scopes = new[] { "https://graph.microsoft.com/.default" };
var tenantId = "yout_tenant_name.onmicrosoft.com";
var clientId = "azure_ad_client_id";
var clientSecret = "client_secret";
var clientSecretCredential = new ClientSecretCredential(
    tenantId, clientId, clientSecret);
var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
var queryOptions = new List<QueryOption>()
{
    new QueryOption("$count", "true")
};
var transitiveMembers = await graphClient.Groups["group_id"].TransitiveMembers.WithODataCast("microsoft.graph.group").Request(queryOptions).Header("ConsistencyLevel","eventual").GetAsync();

我想你可以试试我上面的代码:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM