This project is read-only.

Using LinqToLdap on a Web Project

Nov 22, 2014 at 2:40 PM
Hi, I first wanted to say congrats on this project. It's awesome!

I'm thinking of using it on a web project for user management. So far I've managed to test it on a console app (connect to ldap server, query users, add users and so on) and it's working great.
Now I need to add this functionality to an Mvc Application but I have some design questions that may impact on app performance

I'm connecting to Active Directory and LDS (ADAM) to manage users

Q1: Where should I put my connections configurations?
Q2: How do I use it from Controllers?
Q3: Is there any session related stuff I need to manage not to lose login information or do I need to pass login information to ldap configuration on every request?

I saw on other thread of LinqToLdapExtensions that manages connections on Web apps. Is this the approach I should use?

Thanks, and sorry for asking too many questions (and my very poor english ;) )
Nov 24, 2014 at 9:06 AM

Thanks for the questions and your English is fine :)

I recently updated the front page to try to answer most of these questions, but I'll also include them here:
  1. Your configuration should be done in the Global.asax when your application starts. You should configure it once and then register it with your IoC container (as a singleton) or call UseStaticStorage. This process should also include configuring the connection factory which will create a connection each time using the information you provided. If you use dependency injection you'll also have to include a registration for creation of the DirectoryContext from the LdapConfiguration.
  2. This depends on how you setup your configuration and if you are using dependency injection. You should either receive it as a parameter in your Controller's constructor (if you are using dependency injection) or instantiate it yourself (if you are using UseStaticStorage).
  3. Can you explain this a little more? Are you planning on your users logging in using LINQ to LDAP?
LinqToLdapExtensions is an option and should work, but I'd recommend looking at one of the existing dependency injection frameworks that integrate with ASP.Net MVC (SimpleInjector, Autofac, StructureMap, Ninject, Unity, Castle Windsor, etc.).
Marked as answer by germansak on 1/23/2015 at 1:57 PM
Nov 24, 2014 at 11:33 AM
Hi MadHatter22 thanks for your quick response

Actually I'm developing sort of a Help Desk Web app where you can Add, Delete users in a Lds/Ad domain (CRUD operations). After I wrote this post I found the examples you told me and now I'm digging into them to see how I can structure my app in order to use LinqToLdap. I'll see if I can work it out from there. If I get stuck on something I'll probably ask you again :)

Thanks again for your response and for this amazing project.