title: web.config transform for microsoft.identitymodel configsection
body: <p>How does one go about transforming the audienceUris and federatedAuthentication elements in the microsoft.identitymodel configuration section using the standard visual studio web.config transforms? </p>
  
  <p>For the development environment, we have all the subdomains postfixed with a '-dev' along with special localhost port numbers, for example: realm="https://client-dev.domain.com:444". Today the main web.config reflects this but ideally we would like to move this setting to Web.Debug.config and in the Web.Release.config we would like to specify the proper audience and realms sans the '-dev' postfix and the local port settings. However, attempting to put xdt:Transform="Replace" in the microsoft.identitymodel element inside the Web.Debug.Config results in this warning:</p>
  
  <pre><code>The 'http://schemas.microsoft.com/XML-Document-Transform:transform' attribute is not declared.
  </code></pre>
  
  <p>and of course runtime failures (not being able to find servicecertificate for example). </p>
  
  <p>Here's the microsoft.identitymodel sections:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt;
    &lt;/configSections&gt;
  
    &lt;microsoft.identityModel&gt;
      &lt;service&gt;
        &lt;applicationService&gt;
          &lt;claimTypeRequired&gt;
            &lt;claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier" optional="false" /&gt;
            &lt;claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" optional="false" /&gt;
          &lt;/claimTypeRequired&gt;
        &lt;/applicationService&gt;
        &lt;serviceCertificate&gt;
          &lt;certificateReference x509FindType="FindByThumbprint" findValue="NNNNNNNNNN" storeLocation="LocalMachine" storeName="My" /&gt;
        &lt;/serviceCertificate&gt;
        &lt;certificateValidation certificateValidationMode="None" /&gt;
        &lt;audienceUris&gt;
          &lt;add value="https://url/" /&gt;
        &lt;/audienceUris&gt;
        &lt;federatedAuthentication&gt;
          &lt;wsFederation passiveRedirectEnabled="true" issuer="https://url/" realm="https://url/" requireHttps="true" /&gt;
          &lt;cookieHandler requireSsl="true" /&gt;
        &lt;/federatedAuthentication&gt;
        &lt;issuerNameRegistry type="Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&gt;
          &lt;trustedIssuers&gt;
            &lt;add thumbprint="NNNNNNNNNN" name="https://url/" /&gt;
          &lt;/trustedIssuers&gt;
        &lt;/issuerNameRegistry&gt;
      &lt;/service&gt;
    &lt;/microsoft.identityModel&gt;
  &lt;configuration&gt;
  </code></pre>
  
  <p>Existing solutions that don't work:</p>
  
  <p>1) Same issue was raised here but no proper response. The RemoveAll and Insert doesn't work:
  <a href="https://stackoverflow.com/questions/8513488/web-config-transform-on-microsoft-identitymodel-http-schemas-microsoft-com">Web config transform on microsoft.identityModel - &#39;http://schemas.microsoft.com/XML-Document-Transform&#39; attribute is not declared</a></p>
  
  <p>2) Also, tried to manipulate the namespace as suggested on this thread and this doesn't work either:
  <a href="http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9ededb66-3e34-4bba-8e20-a2cc6025f0f9" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9ededb66-3e34-4bba-8e20-a2cc6025f0f9</a></p>
  
  <p>3) configSource looked promising but again does work when specified in the microsoft.identitymodel element.
  I get:</p>
  
  <pre><code>Warning 1   The 'configSource' attribute is not declared.
  </code></pre>
  
  <p><a href="http://blog.andreloker.de/post/2008/06/16/Keep-your-config-clean-with-external-config-files.aspx" rel="nofollow noreferrer">http://blog.andreloker.de/post/2008/06/16/Keep-your-config-clean-with-external-config-files.aspx</a></p>
  
  <p>Any help will be appreciated! Thanks.</p>