C# Office365通过EWS获取ArchiveGuid

C# Office365通过EWS获取ArchiveGuid,c#,exchangewebservices,ews-managed-api,office365-apps,C#,Exchangewebservices,Ews Managed Api,Office365 Apps,我正在使用此PowerShell命令从办公室获取ArchiveGuid属性: PS > $O365Cred = (Get-Credential) PS > New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $O365Cred -Authentication Basic -AllowRedirection

我正在使用此PowerShell命令从办公室获取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调用中缺少了什么