Share via


Deleting an ACE From an ACL

Deleting an ACE From an ACL

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The following example deletes an access control entry (ACE) from an access control list (ACL).

Visual Basic

'//////////////////////////////////////////////////////////////////////
'
' Function DeleteAce
' Purpose: Delete an Access Control Entry (ACE) from an Access Control List (ACL).
' Input:       dacl            Access Control List (Object)
'              TrusteeName     Name of the Trustee you want to delete
'
' Output:  None
'
' Note:  In order for this example to function correctly, it may be necessary to include
' references to the following libraries: Active DS Type Library, Microsoft CDO for
' Exchange Management Library, Microsoft Cluster Service Automation Classes,
' Microsoft CDO for Windows 2000 Library.
'//////////////////////////////////////////////////////////////////////
Function DeleteAce(ByRef objDacl, _
                   ByRef szTrusteeName)

    Dim objOACE

    On Error Resume Next

    ' Create a temp ACE Object.
    Set objOACE = CreateObject("AccessControlEntry")

        ' Recurse through the ACL.

        For Each objOACE In objDacl

            ' Find the Trustee you are looking to delete.
            If (Trim(LCase(objOACE.Trustee)) = Trim(LCase(szTrusteeName))) Then

                ' Delete the ACE from the ACL
                objDacl.RemoveAce (objOACE)
            End If
        Next

    ' Clean up.
    Set objOACE = Nothing
End Function

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.