如何检索您是否不拥有的文件夹的 acl

注意:这篇文章是由无人工介入的微软自动的机器翻译软件翻译完成。微软很高兴能同时提供给您由人工翻译的和由机器翻译的文章, 以使您能使用您的语言访问所有的知识库文章。然而由机器翻译的文章并不总是完美的。它可能存在词汇,语法或文法的问题,就像是一个外国人在说中文时总是可能犯这样的错误。虽然我们经常升级机器翻译软件以提高翻译质量,但是我们不保证机器翻译的正确度,也不对由于内容的误译或者客户对它的错误使用所引起的任何直接的, 或间接的可能的问题负责。

点击这里察看该文章的英文版: 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;    }				

警告:本文已自动翻译

属性

文章 ID:197743 - 上次审阅时间:01/10/2015 11:39:54 - 修订版本: 2.2

Microsoft Exchange 开发工具包 5.5, Microsoft Exchange Server 2003 Software Development Kit

  • kbnosurvey kbarchive kbmt kbhowto kbmsg KB197743 KbMtzh
反馈