Active Directory query with "SQL"?

I'm just wondering if anyone knows or does a wrapper around Active Directory so that I can easily query for it in .net? For example, "LINQ-to-ActiveDirectory" or some SQL dialect, i.e. Have the ability to "SELECT DISTINCT (DEPARTMENT) FROM / Users / SomeOU / AnotherOU" or "SELECT user FROM domain" or something else.

As far as I know, you can query WMI and IIS using "SQLesque", I just wonder if something like this is possible for Active Directory without learning yet another query language (LDAP)?

+6
active-directory ldap ldap-query
source share
1 answer

LINQ to Active Directory implements a custom LINQ query provider that allows querying objects in Active Directory. Internally, queries are translated into LDAP filters, which are sent to a server that uses the System.DirectoryServices.NET Framework Library.

http://www.codeplex.com/LINQtoAD

Example (from the site):

// NOTE: Entity type definition "User" omitted in sample - see samples in release. var users = new DirectorySource<User>(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(); 
+13
source share

All Articles