active-directory - 读取活动目录 msDS-ReplAttributeMetaData 的权限
问题描述
我需要msDS-ReplAttributeMetaData
在我的 C# 应用程序中从 Active Directory 中读取属性。当我以我的身份运行我的代码时,使用普通DirectorySearcher
用户可以看到比以不同用户身份运行时更多的属性。我的 AD 管理员告诉我帐户之间应该没有区别。
有谁知道我可以让他们查看的特定权限?我要阅读的具体项目是在哪里,pszAttributeName
以便unicodePwd
我可以获得最后的更改日期。
我知道该PwdLastSet
属性,但是当帐户设置为永不过期时,密码将经常具有值 0,因此我必须进入元数据。
这是我用来运行查询的代码。
var searcher = new DirectorySearcher {
SearchRoot = new DirectoryEntry("GC://DC=..."),
SearchScope = SearchScope.Subtree,
Filter = "(&(objectCategory=User)(SamAccountName=...))",
PageSize = 1000
};
var numFound = 0;
try {
searcher.PropertiesToLoad.Clear();
searcher.PropertiesToLoad.Add("msDS-ReplAttributeMetaData");
var result = searcher.FindOne();
foreach (string xml in result.Properties["msDS-ReplAttributeMetaData"]) {
numFound++;
var doc = XDocument.Parse(xml);
var element = doc.XPathSelectElement("//ftimeLastOriginatingChange[../pszAttributeName='unicodePwd']");
if (element == null)
continue;
Console.WriteLine(element.Value);
}
} finally {
searcher.Dispose();
}
Console.WriteLine($"Done - I found {numFound}");
在我的帐户上显示找到 40,而在另一个帐户上显示为 33。
解决方案
尝试使用LDAP://
而不是GC://
. GC 可能会给您不同的结果,因为并非所有属性都复制到全局目录中。该msDS-ReplAttributeMetaData
属性是在您请求时构建的,因此取决于您请求构建它的服务器。因此,它可能只报告实际复制到该服务器的属性。
如果您最终访问不同域上的服务器(如果您的环境中有多个域),则尤其如此。
推荐阅读
- django - 创建后如何禁止更改 Django 字段?
- xml - 需要 XSLT 2.0 帮助 - 分组方式、总和、替换字符串
- python - 如何查看列元素是否在后面的行中交换
- angular - 在角度 7 中,如何使用来自对象的数据填充垫表
- elixir - 外协协会
- facebook - Facebook 错误:SERVER_ERROR:[代码] 1675030 [消息]:查询错误。[额外]:空
- jquery - modal.show 上重复出现的 JQuery 帖子
- apache - weblogic & OHS - 如何通过公共外部端口使我的应用程序可用
- ruby - Redmine 未加载;安装的宝石未加载
- react-native - 有什么方法可以拦截 Android 的重新加载事件吗?