如何擷取的資料夾您未擁有的 ACL

重要:本文是以 Microsoft 機器翻譯軟體翻譯而成,而非使用人工翻譯而成。Microsoft 同時提供使用者人工翻譯及機器翻譯兩個版本的文章,讓使用者可以依其使用語言使用知識庫中的所有文章。但是,機器翻譯的文章可能不盡完美。這些文章中也可能出現拼字、語意或文法上的錯誤,就像外國人在使用本國語言時可能發生的錯誤。Microsoft 不為內容的翻譯錯誤或客戶對該內容的使用所產生的任何錯誤或損害負責。Microsoft也同時將不斷地就機器翻譯軟體進行更新。

按一下這裡查看此文章的英文版本:197743
本文已封存。本文係以「現狀」提供且不會再更新。
結論
本文將告訴您,如何存取不由目前登入的使用者所擁有的公用資料夾的 [存取控制清單 (ACL)。當程式碼範例此用途的特定時相同的程式碼可以很容易地修改存取或修改任何資訊存放區中的任何資料夾 ACL。
其他相關資訊
任何給定的 Microsoft Exchange 資料夾的 「 存取控制清單被包含在該資料夾的 [PR_ACL_DATA] 或 [PR_ACL_TABLE 屬性。

下列函式用來存取 Exchange 資訊儲存庫中的公用資料夾上的 ACL。若要檢閱中 PR_ACL_DATA 屬性資料,您必須取得資料到 SRowSet 結構。取得這項資訊到 SRowSet 結構是以下程式碼的主要目的。

下列程式庫必須以靜態方式連結您的專案:
  • Kernel32.lib
  • User32.lib
  • Version.lib
  • Advapi32.lib
  • Msvcrt.lib
  • Mapi32.lib
  • Edkguid.lib
  • Edkutils.lib
  • Edkmapi.lib
  • Addrlkup.lib
  • Edkdebug.lib
  • Mblogon.lib

程式碼範例

    // TODO: Change these constants to reflect the folder and server of    // interest.    #define STR_FOLDER_NAME "\\IPM_SUBTREE\\AFolder"    #define STR_DN_SERVERNAME "/O=Org/OU=AServer"\          "/CN=Configuration/CN=Servers"\          "/CN=AServer/CN=Org Private MDB"    #include <windows.h>    #include <edk.h>    #include <mapidbg.h>    #include <stdio.h>    #include <conio.h>    #include <mspab.h>    static   LPMAPISESSION    lpSession =                NULL;    static   LPMDB            lpStore =                  NULL;    static   CHAR             szStore[MAX_PATH + 1] =    {0};    static   ULONG            cbEIDStore  =              0;    static   LPENTRYID        lpEIDStore =               NULL;    static   CHAR             szFolder[MAX_PATH + 1] =   {0};    static   LPMAPIFOLDER     lpFolder =                 NULL;    static   ULONG            cbEIDFolder =              0;    static   LPENTRYID        lpEIDFolder =              NULL;    HRESULT Logon ( LPMAPISESSION *pSession )    {      HRESULT hRes = S_OK;      LPMAPISESSION pLocalSession = NULL;      ULONG ulFlags = 0L;      if ( FAILED ( hRes = MAPIInitialize ( NULL ) ) )         goto Quit;      ulFlags = MAPI_EXTENDED |                MAPI_LOGON_UI |                MAPI_EXPLICIT_PROFILE |                MAPI_NEW_SESSION;      if ( FAILED ( hRes = MAPILogonEx ( 0l,                                         NULL,                                         NULL,                                         ulFlags,                                         &pLocalSession ) ) )         goto Quit;      *pSession = pLocalSession;    Quit:      return hRes;    }    HRESULT ModifyACLS ( )    {      LPSRowSet      pRows   =      NULL;      HRESULT        hr =           S_OK;      ULONG          ulUIParam =    0;      LPCIID         lpInterface =  NULL;      ULONG          ulFlags =      MAPI_BEST_ACCESS;      ULONG          ulObjType =    0;      LPSTR          mstr =         NULL;      LPMAPITABLE    m_lpMapiTbl=   NULL;      ULONG          ulFlagsTable = 0;      ULONG          lpulCount =    NULL;      LPMDB          lpMailbox =    NULL;      LPEXCHANGEMODIFYTABLE m_lpExchTbl =   NULL;      SizedSPropTagArray ( 2, sptCols ) = { 2,                                            PR_ENTRYID,                                            PR_DISPLAY_NAME };      // Logon to MAPI Session      hr = Logon ( &lpSession );      if (FAILED(hr))      {         MessageBox(NULL,"MAPI Logon failed",NULL,MB_OK);         goto cleanup;      }      // Get entry ID of the Public Folders store      hr = HrMAPIFindStore(lpSession,                           "Public Folders",                           &cbEIDStore,                           &lpEIDStore);      if (FAILED(hr))      {         MessageBox(NULL,"Message Store Not Found",NULL,MB_OK);         goto cleanup;      }      // Open the Public Folders store      hr = lpSession->OpenMsgStore(ulUIParam,                                   cbEIDStore,                                   lpEIDStore,                                   lpInterface,                                   ulFlags,                                   &lpStore);      if (FAILED(hr))      {         MessageBox(NULL,"Message Store Not Opened",NULL,MB_OK);         goto cleanup;      }      // Logon to server and mailbox - as admin      hr = HrMailboxLogon(lpSession,                          lpStore,                          STR_DN_SERVERNAME,                          NULL, &lpMailbox);      if (FAILED(hr))      {         MessageBox(NULL,"HrMailBoxLogon Failed",NULL,MB_OK);         goto cleanup;      }      strcpy(szFolder, STR_FOLDER_NAME);      // Get entry ID of specific public folder      hr = HrMAPIFindFolderEx(lpMailbox,                              '\\',                              szFolder,                              &cbEIDFolder,                              &lpEIDFolder);      if (FAILED(hr))      {         MessageBox(NULL,"Folder Not Found",NULL,MB_OK);         goto cleanup;      }      // Open the folder in an IMAPIFolder interface      hr = lpMailbox->OpenEntry(cbEIDFolder,                                lpEIDFolder,                                NULL,                                MAPI_BEST_ACCESS,                                &ulObjType,                                (LPUNKNOWN FAR *)&lpFolder);      if (FAILED(hr))      {         MessageBox(NULL,"Folder Could Not Be Opened",NULL,MB_OK);         goto cleanup;      }      // Open the ACL table in an IExchangeModifyTable interface      hr = lpFolder->OpenProperty(PR_ACL_TABLE,                                  (LPGUID)&IID_IExchangeModifyTable,                                  0,                                  MAPI_DEFERRED_ERRORS,                                  (LPUNKNOWN FAR *)&m_lpExchTbl);      if (FAILED(hr))         goto cleanup;      // Open a MAPI table on the ACL table property.  This table can be      // read to determine what the ACL table looks like.      hr = m_lpExchTbl->GetTable(0, &m_lpMapiTbl);      if (FAILED(hr))      {         hr = HR_LOG(E_FAIL);         goto cleanup;      }      hr = m_lpMapiTbl->GetRowCount(ulFlagsTable,&lpulCount);      if (FAILED(hr))      {         goto cleanup;      }      hr = HrQueryAllRows(m_lpMapiTbl,NULL, NULL, NULL, lpulCount,&pRows);      if (FAILED(hr))      {         goto cleanup;      }    // You now have the PR_ACL_DATA in a SRowSet structure.    cleanup:      if (lpSession)      {         lpSession->Logoff(0, 0, 0);         ULRELEASE(lpSession);      }      MAPIUninitialize();      return 0;    }				

警告:本文為自動翻譯

內容

文章識別碼:197743 - 最後檢閱時間:01/10/2015 11:39:54 - 修訂: 2.2

Microsoft Exchange Development Kit 5.5, Microsoft Exchange Server 2003 Software Development Kit

  • kbnosurvey kbarchive kbmt kbhowto kbmsg KB197743 KbMtzh
意見反應