如何授予代理人对系统管理身份的特定 O365 共享邮箱的访问权限

问题描述 投票:0回答:1

系统管理身份是否可以被授予对某些 Office 365 共享邮箱的委托访问权限,然后使用图形 API 查询它们?

我有一个运行 PowerShell 脚本的 Azure 自动化 Runbook,需要访问此类邮箱的日历内容。

由于它是一个 Runbook,所以它在无人值守的情况下运行,我知道我可以授予 Calendars.Read 应用程序 API 权限,但这需要添加创建密钥,然后设置 应用程序访问策略 以防止 Runbook访问整个组织的所有邮箱。

相反,只需将对所需邮箱的委派访问权限授予系统管理身份,就像我们对普通用户所做的那样,使用

Add-MailboxPermission -User <[email protected]>
PowerShell 命令并访问这些邮箱,而不增加任何复杂性。

我尝试运行

Add-MailboxPermission -User
命令并传递系统管理身份的对象(主体)id(GUID),但这不起作用。

azure microsoft-graph-api office365 microsoft-graph-mail exchange-online
1个回答
0
投票

我创建了一个网络应用程序并启用了系统分配的身份

enter image description here

检查用户是否有邮箱:

Connect-ExchangeOnline

Get-Mailbox -Identity [email protected] 

enter image description here

当我尝试通过传递 Add-MailboxPermission

 来运行 
ObjectID
 命令时,我得到了 同样的错误

Add-MailboxPermission -Identity [email protected] -User ManagedIdentityObjectId -AccessRights FullAccess

enter image description here

要解决该错误,您需要通过传递

ObjectID
ApplicationID
显式创建服务主体,如下所示:

搜索系统管理身份企业应用程序:

enter image description here

New-ServicePrincipal -AppId EnterpriseApplicationApplicationID -ServiceId EnterpriseApplicationObjectId

enter image description here

现在 要将邮箱权限添加到托管身份,请从响应中复制

ObjectID
并将其传递到用户参数中:

Add-MailboxPermission -Identity [email protected] -User ObjectId -AccessRights FullAccess

enter image description here

您可以使用以下命令验证

Get-MailboxPermission -Identity [email protected] -User EnterpriseApplicationObjectId

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.