'Modifying Exchange ACL for folders with python

while try to read the ACL Table of a folder, I ran into this problem:

In a C++ tool (MFCMAPI) this method is used to get the Property PR_ACL_TABLE in a usable data type:

// Open the table in an IExchangeModifyTable interface
 EC_H(lpMAPIProp->OpenProperty(
  ulPropTag,
  (LPGUID)&IID_IExchangeModifyTable,
  0,
  MAPI_DEFERRED_ERRORS,
  (LPUNKNOWN FAR *)&lpExchTbl));

I figured out to do this in python win32:

table = mystore.OpenProperty(mapitags.PR_ACL_TABLE, IID_IExchangeModifyTable, 0 , mapi.MAPI_DEFERRED_ERRORS)

But it seems that the MAPI Extension does not know the IID_IExchangeModifyTable type. I just got just this error:

AttributeError: 'module' object has no attribute 'IID_IExchangeModifyTable'

Does anybody know another way to get and modify the ACL data from exchange via the MAPI (and python)?

Thanks - Marquies



Solution 1:[1]

According to the docs, you need a PyIID object.

However, in almost all cases, functions that expect a CLSID/IID as a param will accept either a string object, or a native PyIID object.

That said, I've seen mapi.IID_IMessage used with the OpenProperty method.

Solution 2:[2]

IExchangeModifyTable is declared in edkmdb.h Are you using mapi33 in python? Is that interface even declared in mapi33? You can use RDOFolder.ACL in Redemption (I am its author): http://www.dimastr.com/redemption/rdo/RDOACL.htm

Solution 3:[3]

It looks like you are trying to access the ACL table on a message store object. As far as I know, ACL tables are specific to folder objects and don't exist on message stores. Try using your "mystore" object to open a particular folder within the store, and then call OpenProperty on the folder object to retrieve the ACL table. Make sure you open the folder object with the MAPI_NO_CACHE and MAPI_MODIFY flags specified as well.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mark
Solution 2
Solution 3 Derek