Usage in a multi-thread environment

Mar 29, 2011 at 4:21 PM

Is it possible to use the software in a multi-threaded environment ?

I can imagine usage of this component in a WCF service application. Would this not cause

problems for the static connection factory or other connection related problems ?

I'm not sure but I don't think that there exists something like connection pooling to databases for LDAP repositories.




Mar 31, 2011 at 2:37 AM


The static connection factory can only be configured via ConfigureFactory.  You should only call this once during your app initialization.  You can perform a lock to ensure that it's not configured more than once.

Each DirectoryContext (if using the empty constructor) will get a connection and use it for as long as it is alive so you should scope the DirectoryContext to a unit of work.  This is pretty easy in a situation like a WCF service or a web app since you can just scope it to the lifetime of the request.  If you try to share a context or connection across multiple threads then you'll run into trouble.

From what I've read LdapConnection doesn't really have support for connection pooling.  DirectoryEntry pulls it off but under limited circumstances.  I'll take a look at implementing pooling for LINQ to LDAP.  Thanks for the idea. It's also possible to roll your own if you want because I allow DirectoryContexts to be given an LdapConnection.

Mar 31, 2011 at 3:09 AM
Edited Apr 4, 2011 at 2:59 AM


I've checked in my pooling changes to the trunk and I've written a blog post about it.  Let me know if this works for you.