c# - Edit requiredResourceAccess of Azure AD Application using MVC or C#.NET application
问题描述
I am running PowerShell code from C# app to register an application in Azure AD (create an application in Azure AD).I want to Add and Grant permissions for "Power BI Service" and "Windows Azure Active Directory" on this registered application.
I found that we can also edit the Manifest
of Azure AD application and pass requiredResourceAccess
array. This will automatically add and grant permission for the application.
Please help me with PowerShell commands which can be run using C# code or C# code to edit Manifest
of application so that add grant and permissions to Azure Ad Application programatically.
解决方案
Try the powershell command below, in the sample, it grants the some permissions of Windows Azure Active Directory
api and Power BI Service
api.
$req = New-Object -TypeName "Microsoft.Open.AzureAD.Model.RequiredResourceAccess"
$acc1 = New-Object -TypeName "Microsoft.Open.AzureAD.Model.ResourceAccess" -ArgumentList "311a71cc-e848-46a1-bdf8-97ff7156d8e6","Scope"
$acc2 = New-Object -TypeName "Microsoft.Open.AzureAD.Model.ResourceAccess" -ArgumentList "aaff0dfd-0295-48b6-a5cc-9f465bc87928","Role"
$req.ResourceAccess = $acc1,$acc2
$req.ResourceAppId = "00000002-0000-0000-c000-000000000000"
$reqe = New-Object -TypeName "Microsoft.Open.AzureAD.Model.RequiredResourceAccess"
$acc1e = New-Object -TypeName "Microsoft.Open.AzureAD.Model.ResourceAccess" -ArgumentList "ddb3ca45-a192-477d-acb2-46bf9dc586de","Scope"
$acc2e = New-Object -TypeName "Microsoft.Open.AzureAD.Model.ResourceAccess" -ArgumentList "28379fa9-8596-4fd9-869e-cb60a93b5d84","Role"
$reqe.ResourceAccess = $acc1e,$acc2e
$reqe.ResourceAppId = "00000009-0000-0000-c000-000000000000"
Set-AzureADApplication -ObjectId <ObjectId> -RequiredResourceAccess @($req,$reqe)
推荐阅读
- python - 在 K-Means 中找到 K 时,Elbow 曲线有多可靠?
- android - 列表与详细视图重叠
- unity3d - 我可以在没有项目设置的情况下在 c# 代码中#define 一个常量解决方案范围吗?
- ios - 如何在我的网站中关闭自动睡眠 ios
- c# - SignalR 从客户端发送数据
- android - 如何从签名的消息中恢复地址?
- kubernetes - Kubernetes 的服务仍处于待处理状态。它是如何工作的以及如何解决这个问题?
- javascript - React.js 拼接从数组列表中删除错误的项目
- python - 当我尝试在 django 中进行迁移时,出现未定义的 DJANGO_SETTINGS_MODULE 错误
- android - 从 Glide 获取链接以稍后将其用作资源