Let's say I would like to implement an Extension method that allows me to get the Forest object for every DirectoryEntry object.
My skeleton code:
public static Forest GetForest(DirectoryEntry de) {
string forestDnsName = //DoSomethingWith(de.Path); ?
DirectoryContext context = new DirectoryContext(DirectoryContextType.Forest, forestDnsName);
return Forest.GetForest(context)
}
But I am unsure how I could get the Forest. Does anyone know how to get it?
No sample code, just some general steps:
Forest
object from forest name already If you will call this extension method many times, you may build a domain name to Forest
object map to reduce AD traffic (skip step 4 - 7).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.