活动目录。使用 DACL
我正在尝试创建自己的静态类来与 AD 一起使用。 我编写了一个静态方法:
public static void AddReadingAceForGroup(DirectoryEntry dirEntry, string groupName)
{
dirEntry.RefreshCache();
DirectoryEntry root = new DirectoryEntry("LDAP://192.168.1.1/ dc=mydomain,dc=ru");
using (DirectorySearcher ds = new DirectorySearcher(root, "CN="+groupName))
{
SearchResult sr = ds.FindOne();
root = sr.GetDirectoryEntry();
}
try
{
ActiveDirectoryAccessRule accessRule =
new ActiveDirectoryAccessRule(root.ObjectSecurity.GetGroup(typeof(SecurityIdentifier)),
ActiveDirectoryRights.GenericRead, AccessControlType.Allow);
dirEntry.ObjectSecurity.AddAccessRule(accessRule);
dirEntry.CommitChanges();
}
catch(Exception e)
{
}
}
在使用此函数之前,我使用远程凭据模拟用户,然后代码正常工作,但没有结果。删除 ACE 的类似功能效果很好。
I'm trying to make my own static class to work with AD.
I wrote a static method:
public static void AddReadingAceForGroup(DirectoryEntry dirEntry, string groupName)
{
dirEntry.RefreshCache();
DirectoryEntry root = new DirectoryEntry("LDAP://192.168.1.1/ dc=mydomain,dc=ru");
using (DirectorySearcher ds = new DirectorySearcher(root, "CN="+groupName))
{
SearchResult sr = ds.FindOne();
root = sr.GetDirectoryEntry();
}
try
{
ActiveDirectoryAccessRule accessRule =
new ActiveDirectoryAccessRule(root.ObjectSecurity.GetGroup(typeof(SecurityIdentifier)),
ActiveDirectoryRights.GenericRead, AccessControlType.Allow);
dirEntry.ObjectSecurity.AddAccessRule(accessRule);
dirEntry.CommitChanges();
}
catch(Exception e)
{
}
}
Before using this function I do impersonate user with remote credentials, then code works without exceptions, but have no result. The similar function which removes ACE works fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最终的工作代码是:
我刚刚遇到了组 SID 错误。该代码工作完美,但没有达到我的预期。
抱歉我的英语不好。
The final working code is:
I just had error with group SID. The code works perfect, but do not that what I'm expecting for.
Sorry my bad english.