What is the best way to determine if a user has full mailbox rights to an additional Outlook mailbox?
I am using Redemption to use the Search Folders on a mailbox the user has access to. If they only have editor rights to certain folders they cannot see Search Folders as it is not possible to give permissions to a Search Folder. It seems the only way to make Search Folders visible is if they have full mailbox rights (given via Exchange) so I need to branch my logic depending on whether they have full mailbox rights or not, but I cannot figure out how to do this check.
If I check the access control entry of the root folder for a mailbox I have full rights to using the following code it is null:
var folder = additionalMailbox.RootFolder;
var accessControlList = folder.ACL;
var currentUserRights = accessControlList.ACEofAddressEntry(currentUserAddressEntry);
I did this by testing to see if the user could see the Search Folders on the additional mailbox, as these are only visible if you have full permissions. I then tested the count property of the search folders object, which throws a COMException when there are no search folders:
private bool SearchFoldersVisible(RDOStore2 mailbox)
{
var searchFolders = mailbox.Searches;
try
{
var throwErrorIfNoAccess = searchFolders.Count;
}
catch (COMException)
{
return false;
}
finally
{
Marshal.ReleaseComObject(searchFolders);
}
return true;
}