title: COMException during authentication when managing IIS remotely using Microsoft.Web.Administration
body: <p>Scenario:</p>
  
  <p>I need to remotely administer an IIS server (create and destroy applications) that is on the same domain as the server requesting the changes. I have an application pool set up to run under an authorized account. I have tested remote configuration using the IIS Manager and the account under which the web pool is running successfully so I know the permissions are correct. </p>
  
  <p>The error I get while doing this via code is this.</p>
  
  <pre><code>Type=System.Runtime.InteropServices.COMException
  Source=mscorlib
  Message=Retrieving the COM class factory for remote component with CLSID {2B72133B-3F5B-4602-8952-803546CE3344} from machine &lt;SERVERNAME&gt; failed due to the following error: 800706ba &lt;SERVERNAME&gt;.
  </code></pre>
  
  <p>If I look at the event logs on the remote IIS machine on which I am trying to authenticate with, I see the following error.</p>
  
  <pre><code>Log Name:      Security
  Source:        Microsoft-Windows-Security-Auditing
  Date:          7/13/2011 5:20:22 PM
  Event ID:      4625
  Task Category: Logon
  Level:         Information
  Keywords:      Audit Failure
  User:          N/A
  Computer:      FQDN.local
  Description:
  An account failed to log on.
  
  Subject:
      Security ID:        NULL SID
      Account Name:       -
      Account Domain:     -
      Logon ID:       0x0
  
  Logon Type:         3
  
  Account For Which Logon Failed:
      Security ID:        NULL SID
      Account Name:       UserName
      Account Domain:     DOMAIN
  
  Failure Information:
      Failure Reason:     An Error occured during Logon.
      Status:         0xc00002ee
      Sub Status:     0x0
  
  Process Information:
      Caller Process ID:  0x0
      Caller Process Name:    -
  
  Network Information:
      Workstation Name:   -
      Source Network Address: -
      Source Port:        -
  
  Detailed Authentication Information:
      Logon Process:      Kerberos
      Authentication Package: Kerberos
      Transited Services: -
      Package Name (NTLM only):   -
      Key Length:     0
  
  This event is generated when a logon request fails. It is generated on the computer where access was attempted.
  
  The Subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe.
  
  The Logon Type field indicates the kind of logon that was requested. The most common types are 2 (interactive) and 3 (network).
  
  The Process Information fields indicate which account and process on the system requested the logon.
  
  The Network Information fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases.
  
  The authentication information fields provide detailed information about this specific logon request.
      - Transited services indicate which intermediate services have participated in this logon request.
      - Package name indicates which sub-protocol was used among the NTLM protocols.
      - Key length indicates the length of the generated session key. This will be 0 if no session key was requested.
  Event Xml:
  &lt;Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"&gt;
    &lt;System&gt;
      &lt;Provider Name="Microsoft-Windows-Security-Auditing" Guid="{54849625-5478-4994-A5BA-3E3B0328C30D}" /&gt;
      &lt;EventID&gt;4625&lt;/EventID&gt;
      &lt;Version&gt;0&lt;/Version&gt;
      &lt;Level&gt;0&lt;/Level&gt;
      &lt;Task&gt;12544&lt;/Task&gt;
      &lt;Opcode&gt;0&lt;/Opcode&gt;
      &lt;Keywords&gt;0x8010000000000000&lt;/Keywords&gt;
      &lt;TimeCreated SystemTime="2011-07-13T21:20:22.234292500Z" /&gt;
      &lt;EventRecordID&gt;12046&lt;/EventRecordID&gt;
      &lt;Correlation /&gt;
      &lt;Execution ProcessID="556" ThreadID="8984" /&gt;
      &lt;Channel&gt;Security&lt;/Channel&gt;
      &lt;Computer&gt;FQDN.local&lt;/Computer&gt;
      &lt;Security /&gt;
    &lt;/System&gt;
    &lt;EventData&gt;
      &lt;Data Name="SubjectUserSid"&gt;S-1-0-0&lt;/Data&gt;
      &lt;Data Name="SubjectUserName"&gt;-&lt;/Data&gt;
      &lt;Data Name="SubjectDomainName"&gt;-&lt;/Data&gt;
      &lt;Data Name="SubjectLogonId"&gt;0x0&lt;/Data&gt;
      &lt;Data Name="TargetUserSid"&gt;S-1-0-0&lt;/Data&gt;
      &lt;Data Name="TargetUserName"&gt;UserName&lt;/Data&gt;
      &lt;Data Name="TargetDomainName"&gt;DOMAIN&lt;/Data&gt;
      &lt;Data Name="Status"&gt;0xc00002ee&lt;/Data&gt;
      &lt;Data Name="FailureReason"&gt;%%2304&lt;/Data&gt;
      &lt;Data Name="SubStatus"&gt;0x0&lt;/Data&gt;
      &lt;Data Name="LogonType"&gt;3&lt;/Data&gt;
      &lt;Data Name="LogonProcessName"&gt;Kerberos&lt;/Data&gt;
      &lt;Data Name="AuthenticationPackageName"&gt;Kerberos&lt;/Data&gt;
      &lt;Data Name="WorkstationName"&gt;-&lt;/Data&gt;
      &lt;Data Name="TransmittedServices"&gt;-&lt;/Data&gt;
      &lt;Data Name="LmPackageName"&gt;-&lt;/Data&gt;
      &lt;Data Name="KeyLength"&gt;0&lt;/Data&gt;
      &lt;Data Name="ProcessId"&gt;0x0&lt;/Data&gt;
      &lt;Data Name="ProcessName"&gt;-&lt;/Data&gt;
      &lt;Data Name="IpAddress"&gt;-&lt;/Data&gt;
      &lt;Data Name="IpPort"&gt;-&lt;/Data&gt;
    &lt;/EventData&gt;
  &lt;/Event&gt;
  </code></pre>
  
  <p>I have done a lot of searching on this and have not found anything that seems to point me in the right direction. I did find something that talked about forest trust and that might be the issue but I am not a AD wiz and it all went over my head. I feel like the appropriate permissions are in place since I can get this to work using the IIS Manager just fine, it only fails when using Microsoft.Web.Administration and ServerManager.OpenRemote()</p>
  
  <p>UPDATE</p>
  
  <p>I did disable UAC on both machines and I added the certificate from the target IIS machine to the certificate store on the requesting machine. Still getting the same error.</p>