HOWTO: Use ACL Object to List All Permissions for a MAPI Folder
ID: Q240911
|
The information in this article applies to:
-
Collaboration Data Objects (CDO), versions 1.2, 1.21
SUMMARY
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.
MORE INFORMATION
Use the following steps to display all the permissions on a MAPI folder using the ACL object:
- Register the ACL.dll from the Platform SDK on the computer that you are going to use to run the code that sets the permissions.
- Make sure that the CDO 1.21 library is installed and properly registered on the same computer.
- Create a new Microsoft Visual Basic project.
- Add a reference to both "Microsoft Exchange 5.5 ACL Type Library 1.0" and "Microsoft CDO 1.21 library"
- Cut and paste the following code to the project:
Private Sub Form_Load()
'Setup CDO 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 session
Set CDOSession = CreateObject("MAPI.SESSION")
CDOSession.Logon
'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 session
CDOSession.Logoff
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"
Else
' 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"
Case ROLE_NONEDITING_AUTHOR
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
- Run the code. The permissions for the MAPI folder should be displayed in the Debug window.
Additional query words:
ACL Object
Keywords : kbCDO kbCDO120 kbCDO121 kbMsg kbVBp kbGrpMsg kbDSupport
Version : WINDOWS:1.2,1.21
Platform : WINDOWS
Issue type : kbhowto