|
I think this is basically what' you're looking for.
1) Create the Group class modeling from the example provided in this framework:
2) Create a basic Context class;
sealed class MyContext : DirectoryContext
{
public MyContext(DirectoryEntry searchRoot)
: base(searchRoot)
{
}
[DirectorySearchOptions(SearchScope.Subtree)]
public DirectorySource<ADGroup> Groups { get; set; }
}
3) Query you data. Just sent the OU path to where you want to query.
MyContext ctx = new MyContext(new DirectoryEntry("LDAP://OU=Users,OU=TEST,DC=mydc,DC=com"));
var groups = from x in ctx.Groups
where x.Name.StartsWith("Test")
select x;
foreach (var g in groups)
{
Console.WriteLine(g.Name);
}
|