????? ????? ?????? ?????? Exchange ???????? ????? IExchangeModifyTable MAPI

?????? ????????? ?????? ?????????
???? ???????: 297493 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

?? ??? ??????

??????

??? ????? ?????? ?????? ?????? ??????? ???? Exchange ?? ????? ?????? ??????? (ACL) ???? ???????? ???? ???? ?????? ????? ???????? ????? IExchangeModifyTable. ???? ??? ?????? ????? ????? ?? ????? ?? ????? ?????? ???????? ???????? ??? ???????.

??????? ????

????? ??????? ??????? IExchangeModifyTable::ModifyTable ?????? ?????? ???????? ?? ??? ?????? Exchange. ???? ModifyTable ???? ROWLIST ???? ????? ??? ???? ????? ROWENTRY ???? ?????? ?? ?????? ? ???????? ??? ??? ??????. ?? ???? ROWENTRY ??? ???? ????? ?????? ?? ????? ulRowFlags ???????. ??? ????? ????? ???? ????? SPropValue ???? ????? ??????? ?????? ??????? ?? ??????. ??? ???? ??????:
  • ?????? ?????? ??? ????? ulRowFlags ??? ROW_ADD ?? ????? PR_MEMBER_ENTRYID ??????? PR_MEMBER_RIGHTS SPropValue.
  • ?????? ?????? ??? ????? ulRowFlags ??? ROW_MODIFY ?? ????? PR_MEMBER_ID ??????? PR_MEMBER_RIGHTS SPropValue.
  • ?????? ?????? ??? ????? ulRowFlags ??? ROW_REMOVE ???? PR_MEMBER_ID ?? SPropValue.

????? ????????? ????????

???? Microsoft ??????? ???????? ??? ??? ?? ???? ??????? ?? ?? ????? ? ? ?? ????? ??? ?????? ???????? ??????? ?/?? ???????? ???? ????. ????? ??? ??????? ??? ????? ??? ??? ??????? ???? ?? ????? ???????? ????????? ?????? ????????? ????????. ???? ?? ????? ??????? ????? Microsoft ??? ????? ????? ???? ???? ?? ?????? ?????? ??? ??????? ?????? ????? ?????? ?? ????? ??????? ?????? ????????? ???????.
??? ??? ??? ?? ???? ???? ???? ?????? ?? ???? ???????? ?? ????? ??? ??????? ????? Microsoft ?? ????? ???????. ????? ?? ?????????? ?? ?????? ????? ??? Microsoft ???:

Microsoft ????????? Partners ? https://partner.microsoft.com/global/30000104

????? Microsoft ??????? ???? ???? ??????? - http://support.microsoft.com/gp/advisoryservice

?????? ??? ???? ?? ????????? ??? ?????? ????? ???????? ???? ????? ??????? ????? Microsoft ?? ?????? ???? Microsoft ?????? ??? ?????: http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS?????? "????? ???????? ????????" ? ???? ??????? ???????:
  1. ????? ????? ???? ???? ???????? AppWizard ??????? Win32 ???? ??????, ?? ??? "ModifyTable".
  2. ????? ??? ???? C++ ???? ??????? ?? ??? "ModifyTable.cpp".
  3. ?? ???? ???????? ???????? ??????? ??? ModifyTable.cpp.
    #include <windows.h>
    #include <stdio.h>
    #include "edk.h"
    
    typedef 
    enum ACLRIGHTS
        { 
     RIGHTS_EDIT_OWN = 0x8,
     RIGHTS_EDIT_ALL = 0x20,
     RIGHTS_DELETE_OWN = 0x10,
     RIGHTS_DELETE_ALL = 0x40,
     RIGHTS_READ_ITEMS = 0x1,
     RIGHTS_CREATE_ITEMS = 0x2,
     RIGHTS_CREATE_SUBFOLDERS = 0x80,
     RIGHTS_FOLDER_OWNER = 0x100,
     RIGHTS_FOLDER_CONTACT = 0x200,
     RIGHTS_FOLDER_VISIBLE = 0x400,
     RIGHTS_NONE = 0,
     ROLE_OWNER = 0x5e3,
     ROLE_PUBLISH_EDITOR = 0x4e3,
     ROLE_EDITOR = 0x463,
     ROLE_PUBLISH_AUTHOR = 0x49b,
     ROLE_AUTHOR = 0x41b,
     ROLE_NONEDITING_AUTHOR = 0x413,
     ROLE_REVIEWER = 0x401,
     ROLE_CONTRIBUTOR = 0x402,
     ROLE_NONE = 0x400
        } ACLRIGHTS;
    
    enum {
        ePR_MEMBER_ENTRYID, 
        ePR_MEMBER_RIGHTS,  
        ePR_MEMBER_ID, 
        ePR_MEMBER_NAME, 
        NUM_COLS
    };
    
    SizedSPropTagArray(NUM_COLS, rgPropTag) =
    {
        NUM_COLS,
        {
            PR_MEMBER_ENTRYID,  // Unique across directory.
            PR_MEMBER_RIGHTS,  
            PR_MEMBER_ID,       // Unique within ACL table. 
            PR_MEMBER_NAME,     // Display name.
        }
    };
    
    
    STDMETHODIMP AddUserPermission(
       LPSTR szUserAlias, 
       LPMAPISESSION lpSession,
       LPEXCHANGEMODIFYTABLE lpExchModTbl, 
       ACLRIGHTS frights);
    
    STDMETHODIMP ModifyUserPermission(
       LPSTR szDisplayName, 
       LPEXCHANGEMODIFYTABLE lpExchModTbl, 
       ACLRIGHTS frights);
    
    STDMETHODIMP RemoveUserPermission(
       LPSTR szDisplayName, 
       LPEXCHANGEMODIFYTABLE lpExchModTbl);
    
    void  main()
    {
     HRESULT               hr = NULL;
     LPMAPISESSION         lpSession = NULL;
     LPMDB                 lpPubStore = NULL;
     LPMAPIFOLDER          lpPubFolder = NULL;
     LPMAPIFOLDER          lpMyFolder = NULL;
     LPEXCHANGEMODIFYTABLE lpExchModTbl= NULL; 
     
     hr = MAPIInitialize(NULL);
     if (FAILED(hr)) return;
    
     hr = MAPILogonEx(0,
          NULL,
          NULL,
          MAPI_LOGON_UI | MAPI_NEW_SESSION,
          &lpSession);
     if (FAILED(hr)) goto cleanup0; 
     
     // Open public folder store.
     hr = HrOpenExchangePublicStore(lpSession,
                                 &lpPubStore);
     if (FAILED(hr)) goto cleanup;
     
     // Open all public folders.
     hr = HrOpenExchangePublicFolders(lpPubStore,  
                                   &lpPubFolder);  
     if (FAILED(hr)) goto cleanup;
     
     // Replace with your public folder name.
     hr = HrMAPIOpenSubfolderEx(lpPubFolder, 
                             '\\',
                             "\\MyFolder", 
                             &lpMyFolder);
     if (FAILED(hr)) goto cleanup;
    
     hr = lpMyFolder->OpenProperty(PR_ACL_TABLE, 
                                 &IID_IExchangeModifyTable, 
                                 0, 
                                 MAPI_DEFERRED_ERRORS, 
                                 (LPUNKNOWN*)&lpExchModTbl);
        if(FAILED(hr)) goto cleanup;
    
     // Replace first parameter with user alias.
     // Add user with publishing author rights.
     hr = AddUserPermission(
       "userone", 
       lpSession,
       lpExchModTbl, 
       ROLE_PUBLISH_AUTHOR); 
     
     // Replace first parameter with user display name.
     // Modify user to have reviewer rights.
     hr = ModifyUserPermission(
       "User One", 
       lpExchModTbl, 
       ROLE_REVIEWER);
    
     // Replace first parameter with user display name.
     // Remove user rights.
     hr = RemoveUserPermission(
       "User One", 
       lpExchModTbl);
    
    
    cleanup:
     if (lpExchModTbl) 
      lpExchModTbl->Release();
     
     if (lpMyFolder)
      lpMyFolder->Release();
     if (lpPubFolder)
      lpPubFolder->Release();
     if (lpPubStore)
      lpPubStore->Release();
    
     lpSession->Logoff(0, MAPI_LOGOFF_UI, 0);
     lpSession->Release();
    
    cleanup0:
    
     MAPIUninitialize(); 
     return;
     
    }
    
    
    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;
    }
    
    STDMETHODIMP ModifyUserPermission(
       LPSTR szDisplayName, 
       LPEXCHANGEMODIFYTABLE lpExchModTbl, 
       ACLRIGHTS frights)
    {
     HRESULT      hr = S_OK;
     LPMAPITABLE  lpMapiTbl = NULL;
     ULONG        ulFlagsTable = 0;
     ULONG        lpulCount = NULL;
     LPSRowSet    pRows = NULL;
     UINT         i = 0;
     SPropValue   prop[2] = {0};
     ROWLIST      rowList  = {0};
     BOOLEAN      bFound = false;
     
     // Retrieve MAPI table. 
     hr = lpExchModTbl->GetTable(0,
                              &lpMapiTbl);
     if (FAILED(hr)) goto cleanup;
    
     hr = lpMapiTbl->GetRowCount(ulFlagsTable,
                              &lpulCount);
     if (FAILED(hr)) goto cleanup;
     
     hr = lpMapiTbl->SetColumns((LPSPropTagArray)&rgPropTag, 
                                0 );
     if (FAILED(hr)) goto cleanup;
    
     hr = HrQueryAllRows(lpMapiTbl,
                         NULL, 
                         NULL, 
                         NULL, 
                         lpulCount,
                         &pRows);
     if (FAILED(hr)) goto cleanup;
    
     for (i = 0; i < pRows -> cRows; i++)
     {
      if(PR_MEMBER_NAME == pRows ->aRow[i].lpProps[ePR_MEMBER_NAME].ulPropTag)
      {
       if (!strcmp(pRows -> aRow[i].lpProps[ePR_MEMBER_NAME].Value.lpszA, szDisplayName))
       {
        bFound = true;
        if (PR_MEMBER_ID == pRows -> aRow[i].lpProps[ePR_MEMBER_ID].ulPropTag)
        {
         prop[0].ulPropTag  = PR_MEMBER_ID;
         prop[0].Value.bin.cb = pRows -> aRow[i].lpProps[ePR_MEMBER_ID].Value.bin.cb;
         prop[0].Value.bin.lpb = (BYTE*)pRows -> aRow[i].lpProps[ePR_MEMBER_ID].Value.bin.lpb;
         prop[1].ulPropTag  = PR_MEMBER_RIGHTS;
         prop[1].Value.l   = frights;
    
         rowList.cEntries    = 1;
         rowList.aEntries->ulRowFlags = ROW_MODIFY;
         rowList.aEntries->cValues  = 2;
         rowList.aEntries->rgPropVals = &prop[0];
         
         hr = lpExchModTbl->ModifyTable(0, &rowList);
         if(FAILED(hr)) goto cleanup;
         printf("Modified user permission.\n");
        }
       }
      }
     }
     if (!bFound)
      printf("User not there, no need to modify ...\n");
    cleanup:
     if (lpMapiTbl) 
      lpMapiTbl->Release();
     if (pRows)
      FreeProws(pRows);
     return hr;
    }
    
    STDMETHODIMP RemoveUserPermission(
       LPSTR szDisplayName, 
       LPEXCHANGEMODIFYTABLE lpExchModTbl)
    {
     HRESULT      hr = S_OK;
     LPMAPITABLE  lpMapiTbl = NULL;
     ULONG        ulFlagsTable = 0;
     ULONG        lpulCount = NULL;
     LPSRowSet    pRows = NULL;
     UINT         i = 0;
     SPropValue   prop[1] = {0};
     ROWLIST      rowList  = {0};
     BOOLEAN      bFound = false;
     
     // Retrieve MAPI table.
     hr = lpExchModTbl->GetTable(0, 
                              &lpMapiTbl);
     if (FAILED(hr)) goto cleanup;
    
     hr = lpMapiTbl->GetRowCount(ulFlagsTable,
                              &lpulCount);
     if (FAILED(hr)) goto cleanup;
     
     hr = lpMapiTbl->SetColumns((LPSPropTagArray)&rgPropTag, 
                               0 );
     if (FAILED(hr)) goto cleanup;
    
     hr = HrQueryAllRows(lpMapiTbl,
                         NULL, 
                         NULL, 
                         NULL, 
                         lpulCount,
                         &pRows);
     if (FAILED(hr)) goto cleanup;
    
     for (i = 0; i < pRows -> cRows; i++)
     {
      if(PR_MEMBER_NAME == pRows -> aRow[i].lpProps[ePR_MEMBER_NAME].ulPropTag)
      {
       if (!strcmp(pRows -> aRow[i].lpProps[ePR_MEMBER_NAME].Value.lpszA, szDisplayName))
       {
        printf("Found User to remove\n");
        bFound = true;
        if (PR_MEMBER_ID == pRows -> aRow[i].lpProps[ePR_MEMBER_ID].ulPropTag)
        {
         prop[0].ulPropTag  = PR_MEMBER_ID;
         prop[0].Value.bin.cb = pRows -> aRow[i].lpProps[ePR_MEMBER_ID].Value.bin.cb;
         prop[0].Value.bin.lpb = (BYTE*)pRows -> aRow[i].lpProps[ePR_MEMBER_ID].Value.bin.lpb;
         rowList.cEntries    = 1;
         rowList.aEntries->ulRowFlags = ROW_REMOVE;
         rowList.aEntries->cValues  = 1;
         rowList.aEntries->rgPropVals = &prop[0];
        
         hr = lpExchModTbl->ModifyTable(0,
                                     &rowList);
         if(FAILED(hr)) goto cleanup;
         printf("Removed user permission. \n");
        }
       }
      }
     }
     if (!bFound)
      printf("User not there, no need to remove. \n");
    cleanup:
     if (lpMapiTbl) 
      lpMapiTbl->Release();
     if (pRows)
      FreeProws(pRows);
     return hr;
    }
  4. ?? ???? ??????? ??????? MyFolder ??? ?????? ??????? ????? ?? ??? "???? ???????? ????????".
  5. ?? ???? ??????? ??????? ??????? ?????? ??????? AddUserPermission ?? ?????? ????? ???????? ???? ???? ????? ????? ???????? ??????? ?????? ??? ?? ?? ModifyPermission ?? ????????? RemovePermission ??? ????? ????? ?????????.
  6. ?? ???? AddUserPermission ??????? szServerDN ???? ??? ??????? Exchange ? ??? ??????.
  7. ?? ??????? ??????? ???? ??? ??????? ?? ???? ??? ????? ??????? ??????. ?? ????? ?????? ??????? ??????? ????? edkutils.lib exchsdk.lib mapi32.lib msvcrt.lib kernel32.lib version.lib user32.lib advapi32.lib. ???? ??? ????? ???? ?????? ?????????.
  8. ??????? ??????? ??? ?? ????? ???????.
  9. ??? ???? ?????? ??? ????????? AddUserPermission ? ModifyPermission RemovePermission ?? ???? ???????.
  10. ???? ??? F5 ??? ??????? ? ???? ??? ??????? ??????? ??? ????????.
  11. ???? F10 ??? ?????? ??? ??? ???? ????? ???????. ???? ?? ?????? ?????? ?? Microsoft Outlook ?????? ?? ????? ???????? ??? ???? "?????? ?????".
  12. ???? F10 ??? ???? ????? ?? ????? ?????? ???????? ??? "?????".
  13. ???? F10 ??? ???? ????? ?? ????? ????? ????? ?????????.

???????

???? ???????: 297493 - ????? ??? ??????: 28/???? ??????/1435 - ??????: 5.6
????? ???
  • Microsoft Exchange Server 5.5 Standard Edition
  • Microsoft Exchange 2000 Server Standard Edition
  • ????? ????? ??????? ??????? ?? Microsoft
????? ??????: 
kbnosurvey kbarchive kbmt kbhowto kbmsg KB297493 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????297493

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com