Sub SetExMbxPerms2(ByVal user As DirectoryEntry, ByVal trustee As String)
Const ADS_ACEFLAG_INHERIT_ACE = 2
Const ADS_RIGHT_DS_CREATE_CHILD = 1
Const ADS_ACETYPE_ACCESS_ALLOWED = 0
Dim dacl As New AccessControlList
Dim mailboxRights As New SecurityDescriptor
Dim ace As New AccessControlEntry
Dim mailbox As CDOEXM.IExchangeMailbox = user.NativeObject
mailboxRights = mailbox.MailboxRights
dacl = mailboxRights.DiscretionaryAcl
ace.AccessMask = ADS_RIGHT_DS_CREATE_CHILD
ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED
ace.AceFlags = ADS_ACEFLAG_INHERIT_ACE
ace.Flags = 0
ace.Trustee = trustee
Console.WriteLine(dacl.AceCount)
dacl.AddAce(ace)
Console.WriteLine(dacl.AceCount)
mailboxRights.DiscretionaryAcl = dacl
mailbox.MailboxRights = mailboxRights
user.CommitChanges()
End Sub
|