Tuesday, November 23, 2010


So big side step from my Mad Media Manager series.  Linq to LDAP has been an interest of mine since I found Bart De Smet's awesome Linq to AD.  I downloaded the source and started adding functionality that I thought should be there.  That worked pretty well for a while, but I eventually hit a wall when I wanted to add support for collection Contains operations so that I could do something like this
List<string> strings = new List<string>{"a", "b", "c"};
Expression<Func<MappedObject, bool> expression = 
     e => strings.Contains(e.SomeProperty);
and get a filter that does an “or equal” against the contents of the list.  There are workarounds to supporting this like creating the or condition dynamically, but I felt that I should be able to support it within the framework.  I’m aware that Bart is currently rewriting Linq to AD to support things like this, but I figured I’d take a stab at it myself and learn a lot about Linq and LDAP in the process.  So armed with Matt Warren's blog series I set out to write my own.