【问题标题】:read Parent-GUID attribute from ActiveDirectory using C#使用 C# 从 ActiveDirectory 读取 Parent-GUID 属性
【发布时间】:2018-08-28 09:05:46
【问题描述】:

我想从ActiveDirectory 读取Parent-GUID 属性。

我已尝试使用以下代码从 ActiveDirectory 中读取 AD 对象的所有属性。

代码

var dirEntry = new DirectoryEntry(directoryEntryPath);
var directorySearcher = new DirectorySearcher(dirEntry, filter)
{
    CacheResults = false,
    Tombstone = true,                
};
var searchResult = directorySearcher.FindAll(); // get mutiple AD Objects
foreach (SearchResult search in searchResult)
{
    foreach (DictionaryEntry prop in search.Properties) // here I get all attributes values  But not able to find parent-GUID attribute
    {

    }
}

使用上面的代码,我可以获得 AD 对象的所有属性,但我无法获得 Parent-GUID 属性的值。

【问题讨论】:

    标签: c# active-directory .net-core directoryservices


    【解决方案1】:

    你的意思是这样的吗?:

    string path = "CN=someone,OU=yourOrganizationalUnit,DC=example,DC=com";
    DirectoryEntry root = new DirectoryEntry(path);
    root.Parent.Guid.ToString(); // this will display you the GUID from the parent of your path
    

    希望这就是你的意思!

    干杯,
    ov4rlrd

    【讨论】:

      【解决方案2】:

      根据https://docs.microsoft.com/en-us/windows/desktop/adschema/a-parentguid,这是一个构造属性。这意味着它不会包含在搜索结果中。文档还暗示它支持 DirSync,这告诉我它可能在 DirSync 搜索之外不可用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-14
        • 1970-01-01
        • 1970-01-01
        • 2016-09-08
        相关资源
        最近更新 更多