AAD群组的配额
创始人
2024-05-14 00:15:17
0

AAD群组的配额可以通过Microsoft Graph API进行管理。以下是使用Microsoft Graph API获取和更新AAD群组配额的代码示例:

获取AAD群组配额示例(C#):

using Microsoft.Graph;
using Microsoft.Identity.Client;
using System;

class Program
{
    static async Task Main(string[] args)
    {
        // 配置应用程序身份验证
        var clientId = "YourClientId";
        var clientSecret = "YourClientSecret";
        var tenantId = "YourTenantId";

        var scopes = new string[] { "https://graph.microsoft.com/.default" };

        var app = ConfidentialClientApplicationBuilder
            .Create(clientId)
            .WithClientSecret(clientSecret)
            .WithAuthority($"https://login.microsoftonline.com/{tenantId}")
            .Build();

        // 获取访问令牌
        var authResult = await app.AcquireTokenForClient(scopes)
            .ExecuteAsync();

        // 创建GraphServiceClient实例
        var graphClient = new GraphServiceClient(new DelegateAuthenticationProvider(requestMessage =>
        {
            requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
            return Task.CompletedTask;
        }));

        // 获取AAD群组配额
        var groupQuota = await graphClient.Directory.GetGroupLifecyclePolicies().Request().GetAsync();

        Console.WriteLine($"AAD群组配额:{groupQuota.Value[0].GroupCreationPolicySetting.AllowedGroupTypes}");

        Console.ReadLine();
    }
}

更新AAD群组配额示例(C#):

using Microsoft.Graph;
using Microsoft.Identity.Client;
using System;

class Program
{
    static async Task Main(string[] args)
    {
        // 配置应用程序身份验证
        var clientId = "YourClientId";
        var clientSecret = "YourClientSecret";
        var tenantId = "YourTenantId";

        var scopes = new string[] { "https://graph.microsoft.com/.default" };

        var app = ConfidentialClientApplicationBuilder
            .Create(clientId)
            .WithClientSecret(clientSecret)
            .WithAuthority($"https://login.microsoftonline.com/{tenantId}")
            .Build();

        // 获取访问令牌
        var authResult = await app.AcquireTokenForClient(scopes)
            .ExecuteAsync();

        // 创建GraphServiceClient实例
        var graphClient = new GraphServiceClient(new DelegateAuthenticationProvider(requestMessage =>
        {
            requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
            return Task.CompletedTask;
        }));

        // 更新AAD群组配额
        var groupQuota = await graphClient.Directory.GetGroupLifecyclePolicies().Request().GetAsync();
        groupQuota.Value[0].GroupCreationPolicySetting.AllowedGroupTypes = new string[] { "Unified" };
        await graphClient.Directory.GetGroupLifecyclePolicies().Request().UpdateAsync(groupQuota.Value[0]);

        Console.WriteLine("AAD群组配额已更新");

        Console.ReadLine();
    }
}

请注意,在使用这些代码示例之前,您需要先注册应用程序,并获得相应的客户端ID、客户端密钥和租户ID。

相关内容

热门资讯

玻璃硬盘原理图 玻璃硬盘原理 玻璃硬盘,又称为磁头悬浮硬盘(Magnetic Head Flying Disk,MHFD),是一种...
闲鱼搜索规则与技巧 闲鱼最新特... 在闲鱼这个二手交易平台上,有很多用户都希望能够找到一些特殊的东西,比如一些罕见的收藏品、独特的手工艺...
家里监控最长能保存多少天的记录... 家里监控一般保存多久 随着科技的发展,家庭监控系统已经成为了许多家庭的必备设备,它不仅可以帮助我们...
华为tag有用吗 华为tag-... 华为Tag是华为手机中的一种功能,它可以帮助用户更好地管理自己的手机数据和应用,通过使用华为Tag,...
ps5手柄可用手机快充充电吗 ... PS5手柄,即PlayStation 5的DualSense手柄,是索尼公司为PlayStation...
QQ音乐提示代理模式可能无法正... QQ音乐提示代理模式可能无法正常访问,如上图所示,是怎么回事呢? 这个可能和你的网络设置有关系,首先...
收到微信有提示音怎么去掉 微信... 微信收到信息没有提示音,可能是由多种原因导致的,以下是一些可能的原因及解决方法: 1. 手机静音或...
a100显卡对应的cuda版本 在进行GPU加速的编程中,CUDA是常用的架构和平台,其版本和显卡型号之间存在着一定的对应关系。本篇...
别人打电话听不见我说话怎么回事... 当我们在使用手机时,可能会遇到别人打电话过来听不见声音的情况,这种情况可能是由多种原因导致的,下面我...
网站服务器不稳定怎么解决 外网... 服务器稳定性是任何在线业务的关键,无论是网站、应用还是其他在线服务,有时候,即使我们尽了最大的努力,...