在 Exchange 邮箱上设置 ACL
我正在尝试将组添加到邮箱(在 C# 中)。我混合使用了 CDOEXM、DirectoryServices.AccountManagement 调用,但失败了。这是我的代码:
// userDe is a DirectoryEntry
IExchangeMailbox exMb = (IExchangeMailbox)userDe.NativeObject;
IADsSecurityDescriptor securityDescriptor = (IADsSecurityDescriptor)exMb.MailboxRights;
IADsAccessControlList acl = (IADsAccessControlList)securityDescriptor.DiscretionaryAcl;
AccessControlEntry ace = new AccessControlEntry();
// groupName - I have successfully created the group earlier
ace.Trustee = groupName;
acl.AddAce(ace);
securityDescriptor.DiscretionaryAcl = acl;
exMb.MailboxRights = securityDescriptor;
// How do I save it?
exMb.CommitChanges() etc etc
...or userDe.Properties["ntSecurityDescriptor"] = securityDescriptor;
不确定下一步要做什么,我尝试的所有操作都会导致编译错误或 InvalidCastException。
请帮忙
I'm trying to add a group to a mailbox (in C#). I'm using a mix of CDOEXM, DirectoryServices.AccountManagement calls, and failing. This is my code:
// userDe is a DirectoryEntry
IExchangeMailbox exMb = (IExchangeMailbox)userDe.NativeObject;
IADsSecurityDescriptor securityDescriptor = (IADsSecurityDescriptor)exMb.MailboxRights;
IADsAccessControlList acl = (IADsAccessControlList)securityDescriptor.DiscretionaryAcl;
AccessControlEntry ace = new AccessControlEntry();
// groupName - I have successfully created the group earlier
ace.Trustee = groupName;
acl.AddAce(ace);
securityDescriptor.DiscretionaryAcl = acl;
exMb.MailboxRights = securityDescriptor;
// How do I save it?
exMb.CommitChanges() etc etc
...or userDe.Properties["ntSecurityDescriptor"] = securityDescriptor;
Not sure what to do next, everything I try results in a compilation error or a InvalidCastException.
Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过相当多的痛苦之后才得到它(我设置的整数值在某种程度上对应于 API 中的枚举值,但我无法让它们工作)。变量 userDe 是一个 DirectoryEntry。
Got it after quite a bit of pain (the integer values I am setting somehow correspond to enum values in the API but I couldn't get them to work). The variable userDe is a DirectoryEntry.