我只是想知道是否有人知道或制作了一个围绕Active Directory的包装器,以便能够在.net中轻松查询它?有点像"LINQ-to-ActiveDirectory"或一些SQL方言,即能够做"SELECT DISTINCT(DEPARTMENT)FROM/Users/SomeOU/AnotherOU"或"SELECT user FROM domain"等等.
据我所知,有可能以"SQLesque"方式查询WMI和IIS,我只是想知道Active Directory是否也可以有类似的东西,而不必学习另一种查询语言(LDAP)?
LINQ to Active Directory实现了一个自定义LINQ查询提供程序,该提供程序允许查询Active Directory中的对象.在内部,查询被转换为LDAP过滤器,使用System.DirectoryServices .NET Framework库将其发送到服务器.
http://www.codeplex.com/LINQtoAD
样本(来自网站):
// NOTE: Entity type definition "User" omitted in sample - see samples in release. var users = new DirectorySource(ROOT, SearchScope.Subtree); users.Log = Console.Out; var res = from usr in users where usr.FirstName.StartsWith("B") && usr.Office == "2525" select new { Name = usr.FirstName + " " + usr.LastName, usr.Office, usr.LogonCount }; foreach (var u in res) { Console.WriteLine(u); u.Office = "5252"; u.SetPassword(pwd); } users.Update();