GetSecurityDescriptor for Ex2000 Mailbox
From: Steve Smith (steve.a.smith_at_gov.bc.ca)
Date: 12/22/04
- Previous message: Glen Scales [MVP]: "Re: WEBDAV Exchange Item Based Security - Not Updating"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 22 Dec 2004 08:59:08 -0800
I am developing some code to programmatically add permissions to Exchange
2000 mailboxes for secondary accounts. I am using ADSSecurity.Dll and CDOEXM
in a C# console application.
I am having a problem getting the correct SecurityDescriptor for the
mailbox. My C# function is below. When I execute this code I get no errors,
however the permissions are added to the Account (appearing on the Security
tab in ADUC) rather than on the Mailbox (Mailbox rights on the Exchange
Advanced tab).
Can anyone tell me where I am going wrong?
Thanks in advance
Steve
static void SetExchangeSecurity(string acctToAdd, DirectoryEntry pMailbox,
int accessMask)
{
ActiveDs.AccessControlEntry pNewAce = new ActiveDs.AccessControlEntry();
pNewAce.Trustee = acctToAdd;
pNewAce.AccessMask = accessMask;
pNewAce.AceType =
(int)(ActiveDs.ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOWED );
pNewAce.AceFlags =
(int)(ActiveDs.ADS_ACEFLAG_ENUM.ADS_ACEFLAG_INHERIT_ACE);
CDOEXM.IMailboxStore oMbx = (CDOEXM.IMailboxStore) pMailbox.NativeObject;
try
{
ADSSECURITYLib.ADsSecurity pSec = new ADSSECURITYLib.ADsSecurity();
ActiveDs.IADsSecurityDescriptor pSecDesc =
(ActiveDs.IADsSecurityDescriptor)(pSec.GetSecurityDescriptor(oMbx));
ActiveDs.IADsAccessControlList pAcl =
(ActiveDs.IADsAccessControlList)(pSecDesc.DiscretionaryAcl);
pAcl.AddAce(pNewAce);
pSecDesc.DiscretionaryAcl = pAcl;
pSec.SetSecurityDescriptor(pSecDesc,pMailbox.Path);
pMailbox.CommitChanges();
}
catch (Exception exc)
{
Console.WriteLine(exc);
}
pMailbox.Close();
}
- Previous message: Glen Scales [MVP]: "Re: WEBDAV Exchange Item Based Security - Not Updating"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|