Sunday, November 25, 2007 11:23 PM bart

LINQ to Active Directory (formerly known as LINQ to LDAP) is here

Within a few seconds from now I'll hit the "Publish This Project" button in CodePlex. Back in the early Orcas ages (beta 1 and before) I cooked up this pretty simple example showing how to create custom LINQ query providers. As a matter of fact, it was the result of a blog series back in April entitled "The IQueryable tales". Here are the pointers but keep in mind things have changed in the meantime:

More specifically, the API to write custom LINQ query providers has changed a bit. Most notably is the change that happened in Orcas Beta 2 refactoring the IQueryable<T> interface into IQueryable<T> and IQueryProvider. The new design might be slightly harder to implement (or to wrap your head around initially) but it certainly helps to separate concerns (something that's "queryable" versus the "construction work" that needs to be performed when building up the expression tree). If time permits, I'll reiterate the blog series based on the Orcas RTM APIs.

Now renamed as LINQ to Active Directory (or short: LINQ to AD), this sample allows to write things like this:

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 == "10/2525"
         
select new { Name = usr.FirstName + " " + usr.LastName, usr.Office, usr.LogonCount };

foreach (var u in res)
{
   Console.WriteLine(u);
   u.Office = "10/5252";
   u.SetPassword(pwd);
}

users.Update();

That's right: we have an entity model in place (see samples in the release for more info), allow to do nice mappings (e.g. Office stands for "physicalDeliveryOffice" in AD's User object class), have a simple API that allows adding methods on entities (e.g. SetPassword is a one-line piece of code) and there's update support (change properties as much as you want, just call Update on the DirectorySource object to feed changes back). Cool huh?

So, here it is NOW: LINQ to AD. Enjoy!

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Filed under:

Comments

# LINQ to Active Directory Query Provider

Monday, November 26, 2007 4:12 PM by DotNetKicks.com

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# Link Listing - November 26, 2007

Monday, November 26, 2007 9:16 PM by Christopher Steen

MSBuild MSBuild Task for SharePoint - MakeCab [Via: Steve ] ASP.NET Ajax with the ASP.NET MVC Framework...

# Link Listing - November 26, 2007

Monday, November 26, 2007 9:16 PM by Christopher Steen

Link Listing - November 26, 2007

# The Daily Find #6 - TechToolBlog

Tuesday, November 27, 2007 1:44 PM by The Daily Find #6 - TechToolBlog

Pingback from  The Daily Find #6 - TechToolBlog

# Weekly Link Post 18 &laquo; Rhonda Tipton&#8217;s WebLog

Sunday, December 02, 2007 2:01 PM by Weekly Link Post 18 « Rhonda Tipton’s WebLog

Pingback from  Weekly Link Post 18 &laquo; Rhonda Tipton&#8217;s WebLog

# December 8th Links: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008

Saturday, December 08, 2007 12:14 PM by ScottGu's Blog

Here is the latest in my link-listing series .&#160; Also check out my ASP.NET Tips, Tricks and Tutorials

# December 8th Links: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008

Saturday, December 08, 2007 12:46 PM by BusinessRx Reading List

Here is the latest in my link-listing series .&#160; Also check out my ASP.NET Tips, Tricks and Tutorials

# December 8th Links: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008

Saturday, December 08, 2007 1:00 PM by Elan Hasson's Favorite Blogs

Here is the latest in my link-listing series .&#160; Also check out my ASP.NET Tips, Tricks and Tutorials

# Links del 8 de Diciembre: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008 &laquo; Thinking in .NET

Pingback from  Links del 8 de Diciembre: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008 &laquo; Thinking in .NET

# New and Notable 209

Tuesday, December 11, 2007 6:27 AM by Sam Gentile

Development Tools Snippet Compiler Live 2008 Ultimate Edition for Developers (Alpha) [via Mike ] NAnt

# W&ouml;chentliche Rundablage: ASP.NET MVC, ADO.NET Dataservices (&quot;Astoria&quot;), ASP.NET, LINQ, WPF | Code-Inside Blog

Pingback from  W&ouml;chentliche Rundablage: ASP.NET MVC, ADO.NET Dataservices (&quot;Astoria&quot;), ASP.NET, LINQ, WPF | Code-Inside Blog

# 4 Links Today (2007-12-20)

Thursday, December 20, 2007 7:19 AM by 4 Links Today (2007-12-20)

Pingback from  4 Links Today (2007-12-20)

# December 8th Links: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008

Friday, December 21, 2007 7:42 AM by Developer Blogs

Here is the latest in my link-listing series .&#160; Also check out my ASP.NET Tips, Tricks and Tutorials

# December 8th Links: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008 &laquo; .NET Framework tips

Pingback from  December 8th Links: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008 &laquo; .NET Framework tips

# 12月8日链接篇: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008

Friday, January 18, 2008 10:16 AM by ASP.NET Chinese Blogs

【原文地址】 December 8th Links: ASP.NET, ASP.NET AJAX, ASP.NET MVC, .NET, VS 2008 【原文发表日期】 Saturday, December

# background search company

Sunday, January 20, 2008 12:49 PM by background search company

Many times, you'll get surprised by the mountainous supply of phone news available.

# http://community.bartdesmet.net/blogs/bart/archive/2007/11/25/linq-to-active-directory-formerly-known-as-linq-to-ldap-is-here.aspx

# http://bartdesmet.net/blogs/bart/archive/2007/11/25/linq-to-active-directory-formerly-known-as-linq-to-ldap-is-here.aspx

# LINQ is a better replacement for SQL | ScriptsAhead

Tuesday, August 05, 2008 11:49 AM by LINQ is a better replacement for SQL | ScriptsAhead

Pingback from  LINQ is a better replacement for SQL | ScriptsAhead

# New and Notable 209

Tuesday, December 02, 2008 4:05 PM by Sam Gentile's Blog

Development Tools Snippet Compiler Live 2008 Ultimate Edition for Developers (Alpha) [via Mike ] NAnt 0.86 Beta 1 Release [via Mike ] BizTalk Composite Services using Oracle ESB Routing Services Dealing with cXML based messages in BizTalk WCF/ADFS/Authentication

# linq by marola - Pearltrees

Tuesday, January 10, 2012 7:34 PM by linq by marola - Pearltrees

Pingback from  linq by marola - Pearltrees