title: How to extend a generic?
body: <p>I have an Active Directory service I've made to help me manage basic tasks from within an ASP.NET MVC 3 application (although in reality it can be any .NET application since it's in a separate assembly). I have one base interface and class, <code>IActiveDirectoryService&lt;TPrincipal&gt;</code> and <code>ActiveDirectoryService&lt;TPrincipal&gt;</code>. These get extended one level up to <code>IUserPrincipalService</code> and <code>UserPrincipalService</code>, like this:</p>
  
  <pre><code>IUserPrincipalService : IActiveDirectoryService&lt;UserPrincipal&gt; {
  }
  
  UserPrincipalService : ActiveDirectoryService&lt;UserPrincipal&gt;, IUserPrincipalService {
  }
  </code></pre>
  
  <p>Using Ninject I create a singleton instance of <code>IUserPrincipalService</code> passing in the <code>PrincipalContext</code> I want it to use. This works perfectly fine, but I now have to create multiple instances for each OU I want to add users to, and that's not going to work with Ninject because the names will conflict.</p>
  
  <p>I need to find a way to pass into this service the specific OU I want. I thought about extending the interfaces to something like <code>ICityStateUserPrincipalService : IUserPrincipalService</code> and changing the constructor with Ninject. The problem with this is that I have to make one of these services for each OU we have right now (which happen to be seven). Also, in the future if we need to add a new OU, I have to make it in AD then create a new interface for it as well.</p>
  
  <p>This just doesn't feel right. It would also have to be done within the ASP.NET MVC 3 application, which feels like it's adding bloat and cheats to it. I can't add it to my assembly which houses the current services because I want to keep that generic in case I need to use it across different projects.</p>
  
  <p>Is there a way to both keep what I have now, and make it extendable so I can pass in the path of a specific OU?</p>
  
  <p>The title of the question is probably not very good at all. I'm open to suggestions for changing it, I just couldn't figure out how to phrase it...</p>