我正在使用这个 PowerShell 命令从 Office 获取 ArchiveGuid 属性:
PS > $O365Cred = (Get-Credential)
PS > New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $O365Cred -Authentication Basic -AllowRedirection
PS > Import-PSSession $session
PS > Get-Mailbox -Archive
PS > Get-Mailbox me@example.com |fl arch*
...我得到了一些有用的数据以及 ArchiveGuid 属性,它的值是一个漂亮的 GUID:
ArchiveDatabase : NAMPR08DG002-db090
ArchiveGuid : d9c4eced-a410-41a7-bbfe-ebfd7a1a3b2e
ArchiveName : {In-Place Archive - my name}
ArchiveQuota : 100 GB (107,374,182,400 bytes)
ArchiveWarningQuota : 90 GB (96,636,764,160 bytes)
ArchiveDomain :
ArchiveStatus : Active
ArchiveState : Local
ArchiveRelease :
但在我的 .NET 应用程序中,我想使用 EWS 托管 API 获取此 GUID。
我尝试像这样翻译上面的命令:
ExchangeService svc = new ExchangeService();
svc.Credentials = new WebCredentials("me@example.com", "password", "example.com");
svc.AutodiscoverUrl("me@example.com", MyAutodiscoverRedirectionUrlValidationCallback);
GetSearchableMailboxesResponse resp = svc.GetSearchableMailboxes("arch*", false);
但我收到此错误消息:
The caller has not assigned any of the RBAC roles requested in the management role header
我怎样才能通过这个错误?PowerShell 命令有效,我在 EWS 调用中缺少什么?