0

I develop an application connecting LDAP. In .NET framework there's a namespace System.DirectoryServices.Protocols with set of classes dedicated to handle LDAP queries.

Basically there are two classes:

  • SearchRequest
  • SearchResponse

To query LDAP SearchRequest requires following arguments:

  • string distinguishedName
  • string ldapFilter
  • SearchScope searchScope
  • params string[] attributeList

The thing I don't like about this approach is ldapFilter parameter. It requires query in LDAP format (for instance (|(sn=SomeSurname)(givenName=SomeFirstname)). My idea is to create some mapping to allow developers to query LDAP in a convenient way, namely using LINQ.

I want to create following method:

List<User> GetByFilter(Expression<Func<User, bool>> filter)

POCO User represents LDAP user and filter allow to query LDAP using LINQ in a .NET manner.

The problem is that mapping between expression tree and LDAP query is a complex issue. I've done some research on the Internet, but I haven't found anything. Does anyone know if there's any mapper for this? Is there any .NET library or maybe Entity/nHibernate driver to do this?

Arkadiusz Kałkus
  • 17,101
  • 19
  • 69
  • 108
  • 1
    I've never used it myself (I'm too fond of the lovely LDAP filters syntax, I'm afraid), but there is a Linq to LDAP library at https://linqtoldap.codeplex.com/. There are also several other questions about it on SO. – Paolo Tedesco Dec 15 '15 at 09:56
  • Here is a nice resource for Linq providers: http://blogs.msdn.com/b/charlie/archive/2006/10/05/links-to-linq.aspx – Paolo Tedesco Dec 15 '15 at 09:58

0 Answers0