How To Use ACL Object and CDO (1.21) to List Folder Permissions for a MAPI Folder

Article translations Article translations
Article ID: 240911 - View products that this article applies to.
This article was previously published under Q240911
Expand all | Collapse all


When you use the Access Control List (ACL) object that is included in the Platform SDK, you can set, modify, list, and delete permissions on MAPI folders.

This article describes how to display all the permissions on a MAPI folder programmatically using the ACL object.


Use the following steps to display all the permissions on a MAPI folder using the ACL object:
  1. Register the ACL.dll file on the computer that you are going to use to run the code that sets the permissions.

    NOTE: ACL.dll is not available as a compiled DLL. It is a sample that ships in the Platform SDK and must be compiled before it can be used. This sample wraps the supported MAPI interfaces so that they can be manipulated in languages other than C++. For more information, search on ACLASP on the Microsoft Developer Network (MSDN).
  2. Make sure that the CDO (1.2, 1.21) library is installed and properly registered on the same computer.
  3. Create a new Microsoft Visual Basic project.
  4. Add a reference to both "Microsoft Exchange 5.5 ACL Type Library 1.0" and "Microsoft CDO 1.2 library" or "Microsoft CDO 1.21 library"
  5. Cut and paste the following code to the project:
       Private Sub Form_Load()
           'Setup CDO (1.2, 1.21) objects for use
           Dim CDOSession As MAPI.Session
           Dim CDOFolder As Folder
           'Setup ACL Objects
           Dim ACLObj As MSExchangeACLLib.ACLObject
           Dim FolderACEs As MSExchangeACLLib.IACEs
           Dim NewAce As ACE
           'Setup Misc
           Dim x As Integer
           'Create the CDO (1.2, 1.21) session
           Set CDOSession = CreateObject("MAPI.SESSION")
           'Create the ACL object
           Set ACLObj = CreateObject("MSExchange.aclobject")
           'Get the Inbox folder
           Set CDOFolder = CDOSession.GetDefaultFolder(CdoDefaultFolderInbox)
           ' Associate the ACLObject to the CDO Folder
           ACLObj.CDOItem = CDOFolder
           Set FolderACEs = ACLObj.ACEs
           ' Loop through all of the ACEs for the folder and display them
           For x = 1 To FolderACEs.Count
               Debug.Print CDOFolder.Name & " : " &    GetACLEntryName(FolderACEs.Item(x).ID, CDOSession) & " - " &    DispACERules(FolderACEs.Item(x))
           Next x
           ' Clean up objects
           Set FolderACEs = Nothing
           Set CDOFolder = Nothing
           Set ACLObj = Nothing
           ' Logoff the CDO (1.2, 1.21) session
           Set CDOSession = Nothing
       End Sub
       Public Function GetACLEntryName( _
                          ACLEntryID As String, _
                          SubSession As MAPI.Session)
        ' This function finds the user that is listed as an ACE on the folder.
        ' It takes the ID that it is passed and uses the Session.GetAddressEntry method
        ' to find the name.
        Dim tmpEntry As AddressEntry
        Dim tmpName As String
        If ACLEntryID = "ID_ACL_DEFAULT" Then
            ' The default ACE
            GetACLEntryName = "Default"
            ' Get the name of the ACE
            Set tmpEntry = SubSession.GetAddressEntry(ACLEntryID)
            tmpName = tmpEntry.Name
            GetACLEntryName = tmpName
        End If
       End Function
       Public Function DispACERules(DisptmpACE As ACE)
        ' This function checks the roles of the ACE that is passed to it and    returns
        ' the Role back.
        ' Check the roles on the folder
        Select Case DisptmpACE.Rights
            Case ROLE_NONE, 0  ' Checking in case the role has not been set on that entry.
                    DispACERules = "None"
            Case ROLE_AUTHOR
                    DispACERules = "Author"
            Case ROLE_CONTRIBUTOR
                    DispACERules = "Contributor"
            Case 1147  ' Check value since ROLE_EDITOR is incorrect
                    DispACERules = "Editor"
                    DispACERules = "Nonediting Author"
            Case 2043  ' Check value since ROLE_OWNER is incorrect
                    DispACERules = "Owner"
            Case ROLE_PUBLISH_AUTHOR
                    DispACERules = "Publishing Author"
            Case 1275  ' Check value since ROLE_PUBLISH_EDITOR is incorrect
                    DispACERules = "Publishing Editor"
            Case ROLE_REVIEWER
                    DispACERules = "Reviewer"
            Case Else
            ' This will grab all other custom permissions on the folder
                    DispACERules = "Custom"
        End Select
       End Function
  6. Run the code. The permissions for the MAPI folder should be displayed in the Debug window.


Article ID: 240911 - Last Review: July 13, 2004 - Revision: 2.2
  • Microsoft Collaboration Data Objects 1.2
  • Microsoft Collaboration Data Objects 1.21
kbhowto kbmsg KB240911
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback


Contact us for more help

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