[python-win32] Retrieve User Entry IDs from MAPI

Patrick Breucking breucking at gonicus.de
Fri Sep 17 11:51:39 CEST 2010


Hi folks,

I extended the win32comext MAPI with the Interface IExchangeModifyTable to edit ACLs via the MAPI. I can modify existing ACL entries, but I stuck in adding new entries. I need the users entry ID to add it, according this C example 

(http://support.microsoft.com/?scid=kb%3Ben-us%3B297493&x=14&y=15)

STDMETHODIMP AddUserPermission(
   LPSTR szUserAlias, 
   LPMAPISESSION lpSession,
   LPEXCHANGEMODIFYTABLE lpExchModTbl, 
   ACLRIGHTS frights)
{
 HRESULT     hr = S_OK;
 LPADRBOOK   lpAdrBook;  
 ULONG       cbEid;
 LPENTRYID   lpEid = NULL;
 SPropValue  prop[2] = {0};
 ROWLIST     rowList  = {0};
 
 char szExName[MAX_PATH]; 
 // Replace with "/o=OrganizationName/ou=SiteName/cn=Recipients/cn="
 char* szServerDN = "/o=org/ou=site/cn=Recipients/cn=";

 strcpy(szExName, szServerDN);
 strcat(szExName, szUserAlias);

 // Open the address book.
 hr = lpSession->OpenAddressBook(0,
                                 0, 
                                 MAPI_ACCESS_MODIFY, 
                                 &lpAdrBook );
 if ( FAILED( hr ) ) goto cleanup;

 // Obtain the entry ID for the recipient.
 hr = HrCreateDirEntryIdEx(lpAdrBook, 
                           szExName, 
                           &cbEid, 
                           &lpEid);
 if ( FAILED( hr ) ) goto cleanup;
 
 prop[0].ulPropTag  = PR_MEMBER_ENTRYID;
 prop[0].Value.bin.cb = cbEid;
 prop[0].Value.bin.lpb = (BYTE*)lpEid;
 prop[1].ulPropTag  = PR_MEMBER_RIGHTS;
 prop[1].Value.l   = frights;

 rowList.cEntries = 1;
 rowList.aEntries->ulRowFlags = ROW_ADD;
 rowList.aEntries->cValues  = 2;
 rowList.aEntries->rgPropVals = &prop[0]; 

 hr = lpExchModTbl->ModifyTable(0, &rowList);
 if(FAILED(hr)) goto cleanup;
 printf("Added user permission. \n");

cleanup:
 if (lpAdrBook)
  lpAdrBook->Release();
 return hr;
}


I can open the Address Book, but HrCreateDirEntryIdEx is not provided in the pywin32 mapi. I found it in the exchange extension, which does not compile on my system, the missing library problem. Do you have any idea to retrieve the users entry ID?

Thank.

- Patrick 



More information about the python-win32 mailing list