简体   繁体   中英

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. I've noticed in the VS Object Browser that the Permissions property is on the Folder class.

So I'm guessing I need to get the MailBox object and then get the root/default folder so I can get the Permissions.

This is what I've done so far, but when it calls 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. But passing ExchangeVersion.Exchange2007_SP1 does work when I try and get the Public Folders root folder.

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

So the question is how can I get a MailBoxes permissions using EWS?

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.

So it looks like it's not possible to get the MailBox permissions using EWS. Shame.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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