C# 获取OU的完全限定名
我有一个代码来获取域内的OU列表 现在,这只是列出了所有OU,并没有给出任何方法来区分OU和子OUC# 获取OU的完全限定名,c#,asp.net,active-directory,ldap,ou,C#,Asp.net,Active Directory,Ldap,Ou,我有一个代码来获取域内的OU列表 现在,这只是列出了所有OU,并没有给出任何方法来区分OU和子OU DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain); DirectorySearcher mySearcher = new DirectorySearcher(entry); mySearcher.Filter = ("(objectClass=organizationalUnit)"); foreach (SearchR
DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain);
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=organizationalUnit)");
foreach (SearchResult temp in mySearcher.FindAll())
{
OU_DownList.Items.Add(temp.Properties["name"][0].ToString());
}
有没有办法获得OU的完全限定名称
对于子OU,类似这样的内容:
CN=Computer1,OU=Department 101,OU=Business Unit #1,DC=us,DC=xyz,DC=com
感谢您的帮助。。。谢谢
temp.Path
应该为您获取每个OU的可识别名称。temp.Path
应该为您获取每个OU的可识别名称。使用搜索结果
中的属性Path
,如temp.Path
中所述,请参阅
Path属性唯一标识
Active Directory中的此项
等级制度条目始终可以是
使用此路径检索
您可以使用以下源代码枚举所有可用属性:
foreach(string propKey in temp.Properties.PropertyNames)
{
// Display each of the values for the property identified by
// the property name.
foreach (object property in temp.Properties[propKey])
{
Console.WriteLine("{0}:{1}", propKey, property.ToString());
}
}
使用
SearchResult
中的属性Path
,如temp.Path
中所述,请参阅
Path属性唯一标识
Active Directory中的此项
等级制度条目始终可以是
使用此路径检索
您可以使用以下源代码枚举所有可用属性:
foreach(string propKey in temp.Properties.PropertyNames)
{
// Display each of the values for the property identified by
// the property name.
foreach (object property in temp.Properties[propKey])
{
Console.WriteLine("{0}:{1}", propKey, property.ToString());
}
}
嘿,非常感谢。。有没有办法将上面的字符串显示为businessunit/department 101hey非常感谢。。有没有办法将上面的字符串显示为businessunit/department 101hey Thank buddy但是有没有办法将上面的完全限定名“CN=Computer1,OU=department 101,OU=businessunit#1,DC=us,DC=xyz,DC=com”显示为。。businessunit/department 101
string.Join(“/”,temp.Path.Split(“,”).Select(s=>s.StartsWith(“OU”).Reverse().ToArray())
hey Thank buddy buddy,但是有没有办法将上面的完全限定名“CN=Computer1,OU=department 101,OU=businessunit#1,DC=us,DC=xyz,DC=com”显示为。。业务单元/部门101string.Join(“/”,temp.Path.Split(“,”)。选择(s=>s.StartsWith(“OU”)。Reverse().ToArray())