title: SolrNet with Castle Windsor and basic authentication
body: <p>I use Windsor container in purpose of SolrNet multicore access, but my Solr cores requires basic authentication. Is it possible use SolrNet Windsor intergation with authentication?</p>
  
  <p>I'm tried next:</p>
  
  <pre><code>static SolrInteractServer()
      {
          container.Register(Component.For&lt;ISolrConnection&gt;().ImplementedBy&lt;SolrConnection&gt;().DependsOn(Property.ForKey&lt;IHttpWebRequestFactory&gt;().Eq(new WebAuthentication("login", "password"))));
      }
  
  private static WindsorContainer container = new WindsorContainer();
  
  public static void RegisterFacility&lt;T&gt;(IEnumerable&lt;string&gt; coreUrls, string baseHttpUrl = null)
      {
          SolrNetFacility facility = null;
          if (baseHttpUrl != null)
          {
              facility = new SolrNetFacility(baseHttpUrl);
          }
          else
          {
              facility = new SolrNetFacility();
          }
          foreach (var httpUrl in coreUrls)
          {
              var coreName = "core_" + Guid.NewGuid();
              facility.AddCore(coreName, typeof(T), httpUrl);
              RegisteredCores.Add(coreName, new KeyValuePair&lt;Type, string&gt;(typeof(T), httpUrl));
          }
  
          container.AddFacility("solr", facility);
      }
  
      public static Dictionary&lt;string, KeyValuePair&lt;Type, string&gt;&gt; RegisteredCores = new Dictionary&lt;string, KeyValuePair&lt;Type, string&gt;&gt;();
  </code></pre>
  
  <p>When I run container.AddFacility throws:</p>
  
  <blockquote>
    <p><em>Component SolrNet.Impl.SolrConnection could not be registered. There is already a  component with that name. Did you want to modify the
    existing component instead? If not, make sure you specify a unique
    name.</em></p>
  </blockquote>
  
  <p>and stack trace: </p>
  
  <blockquote>
    <p>at
    Castle.MicroKernel.SubSystems.Naming.DefaultNamingSubSystem.Register(IHandler
    handler)    at
    Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.RegisterHandler(String
    name, IHandler handler, Boolean skipRegistration)    at
    Castle.MicroKernel.Handlers.DefaultHandlerFactory.Create(ComponentModel
    model, Boolean isMetaHandler)    at
    Castle.MicroKernel.DefaultKernel.AddCustomComponent(ComponentModel
    model, Boolean isMetaHandler)    at
    Castle.MicroKernel.DefaultKernel.AddCustomComponent(ComponentModel
    model)    at
    Castle.MicroKernel.Registration.ComponentRegistration<code>1.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal
    kernel)    at
    Castle.MicroKernel.DefaultKernel.Register(IRegistration[]
    registrations)    at
    Castle.Facilities.SolrNetIntegration.SolrNetFacility.Init() in
    g:\prg\SolrNet\Castle.Facilities.SolrNetIntegration\SolrNetFacility.cs:line
    80    at
    Castle.MicroKernel.Facilities.AbstractFacility.Castle.MicroKernel.IFacility.Init(IKernel
    kernel, IConfiguration facilityConfig)    at
    Castle.MicroKernel.DefaultKernel.AddFacility(IFacility facility)    at
    Castle.MicroKernel.DefaultKernel.AddFacility(String key, IFacility
    facility)    at Castle.Windsor.WindsorContainer.AddFacility(String
    idInConfiguration, IFacility facility)    at
    SolrInteractionLogic.Core.SolrInteractServer</code>1.RegisterFacility[T](IEnumerable`1
    coreUrls, String baseHttpUrl) in D:\1. Job projects\1. In
    Progress\Semantic
    Force\Reporting\SFDigestGenerator\SolrInteractionLogic\Core\SolrInteractServer.cs:line
    58    at SolrInteractionTest.Program.Main(String[] args) in D:\1. Job
    projects\1. In Progress\Semantic
    Force\Reporting\SFDigestGenerator\SolrInteractionTest\Program.cs:line
    26    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,
    String[] args)    at
    Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br>
    at System.Threading.ExecutionContext.Run(ExecutionContext
    executionContext, ContextCallback callback, Object state, Boolean
    ignoreSyncCtx)    at
    System.Threading.ExecutionContext.Run(ExecutionContext
    executionContext, ContextCallback callback, Object state)    at
    System.Threading.ThreadHelper.ThreadStart()</p>
  </blockquote>