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?