我正在进行某种健康监测,我想验证我的应用程序在Active Directory中是否有访问权限和正确的权限。当我初始化DirectoryEntry时,这将显示我从机器上看到给定的域/路径。没关系,但我需要检查我是否能够在域中读写。在AD中即使不创建实际对象也是可能的吗?
谢谢
发布于 2016-12-08 16:10:26
最后,奥多夫特的评论非常容易。下面是我使用的代码:
using (DirectoryEntry entry = directorySearcher.FindOne()?.GetDirectoryEntry())
{
if (entry == null)
{
//report error
}
entry.RefreshCache(new string[] { "allowedAttributesEffective" });
if (entry.Properties["allowedAttributesEffective"].Value != null)
{
if (this.properties == null || this.properties.All(property => entry.Properties["allowedAttributesEffective"].Contains(property)))
{
//sufficient rights
}
else
{
//insufficient rights
}
}
else
{
//not possible to check attribute "allowedAttributesEffective", it is missing or you have insufficient rights to read it
}
}https://stackoverflow.com/questions/40929103
复制相似问题