简体   繁体   English

使用EWS获取邮箱权限

[英]Get Mailbox Permissions using EWS

I'm creating an app that needs to get the permissions for each MailBox, and I can't seem to get it to work. 我正在创建一个需要获取每个MailBox权限的应用程序,我似乎无法让它工作。 I've noticed in the VS Object Browser that the Permissions property is on the Folder class. 我在VS对象浏览器中注意到Permissions属性在Folder类上。

So I'm guessing I need to get the MailBox object and then get the root/default folder so I can get the Permissions. 所以我猜我需要获取MailBox对象,然后获取root / default文件夹,以便我可以获得权限。

This is what I've done so far, but when it calls Folder rootfolder = Folder.Bind(service, sharedMailboxRootFolderId); 这是我到目前为止所做的,但是当它调用Folder rootfolder = Folder.Bind(service, sharedMailboxRootFolderId); I get the following exception: 我得到以下异常:

"The Client Access Server version does not match the accessed resource's Mailbox Server version." “客户端访问服务器版本与访问资源的邮箱服务器版本不匹配。”

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
string exchangeServerWebServicesUrl = "https://example.com/EWS/Exchange.asmx";
service.Url = new Uri(exchangeServerWebServicesUrl);

string username = "*********************";
string password = "*********************";

service.UseDefaultCredentials = false;
service.Credentials = new WebCredentials(username, password);

Mailbox sharedMailbox = new Mailbox("shared@example.com");

FolderId sharedMailboxRootFolderId = new FolderId(WellKnownFolderName.Root, sharedMailbox);
Folder rootfolder = Folder.Bind(service, sharedMailboxRootFolderId);

var permissions = rootfolder.Permissions;

I've tried passing in different ExchangeVersion enum values, but they don't work either. 我尝试传递不同的ExchangeVersion枚举值,但它们也不起作用。 But passing ExchangeVersion.Exchange2007_SP1 does work when I try and get the Public Folders root folder. 但是当我尝试获取Public Folders根文件夹时,传递ExchangeVersion.Exchange2007_SP1确实有效。

Folder rootfolder = Folder.Bind(service, WellKnownFolderName.PublicFoldersRoot);

So the question is how can I get a MailBoxes permissions using EWS? 所以问题是如何使用EWS获得MailBoxes权限?

I've just found the Find out which users have Full Access on a mailbox post that says 我刚刚发现找出哪些用户在邮箱帖子上有完全访问权限

You can't using EWS (or any of the Exchange Mailbox API's) you can only access the Folder level DACL's what you need to read is the Mailbox DACL which can only be either accessed via the Exchange Management Shell (Get-MailboxPermissions) or via reading the msexchmailboxsecuritydescriptor from Active Directory. 您不能使用EWS(或任何Exchange邮箱API),您只能访问文件夹级别DACL,您需要阅读的是Mailbox DACL,它只能通过Exchange命令行管理程序(Get-MailboxPermissions)或通过从Active Directory中读取msexchmailboxsecuritydescriptor。

So it looks like it's not possible to get the MailBox permissions using EWS. 所以看起来不可能使用EWS获得MailBox权限。 Shame. 耻辱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM