<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="www.w3.org/2005/Atom" xmlns:sy="purl.org/rss/1.0/modules/syndication/" xmlns:dc="purl.org/dc/elements/1.1/" xmlns:content="purl.org/rss/1.0/modules/content/" xmlns:wfw="wellformedweb.org/CommentAPI/" xmlns:slash="purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Distributed Services: Notes from the field</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/dsnotes/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/dsnotes/feed.xml</link>
    <description>One Stop for Windows Communication Foundation, Microsoft Distributed Services and Com+ Solutions</description>
    <lastBuildDate>Mon, 03 Sep 2018 19:08:02 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>WIF: CryptographicException: Key not valid for use in specified state | solve using matching machine keys</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/wif-cryptographicexception-key-not-valid-for-use-in-specified-state-solve-using-matching-machine-keys</link>
      <pubDate>Mon, 03 Sep 2018 19:08:02 GMT</pubDate>
      <dc:creator><![CDATA[Suresh Butti]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=3265</guid>
      <description><![CDATA[I had a customer who has a claim aware ASP.NET web application hosted on two IIS servers behind a...]]></description>
      <content:encoded><![CDATA[I had a customer who has a claim aware ASP.NET web application hosted on two IIS servers behind a load balancer.

&nbsp;

<strong><u>Scenario</u></strong>:

They had a requirement where they would want to stop (bring down) server1 to perform some patch or maintenance activity. However, they did not want the users are being served by the affected server (server1) and use the same cookies that are set by server1 so that the load balancer would redirect the request to server2 and work seamlessly.

&nbsp;

For testing this, we made a request to the web app from a client machine. We know whether the requested reached either Server1 or Server2 from IIS logs. Let say the request was served by Server1. We manually went to the IIS sever1 and stopped the application corresponding to the application.

On the client, when navigated to a different page with logged in session, LB identified the Server1 is down and redirected the request to server2.

&nbsp;

Then, we ran into the following exception:

&nbsp;
<div style="font-family: Consolas">

<span style="background-color: #ffff00">CryptographicException: Key not valid for use in specified state.</span>

&nbsp;

System.Security.Cryptography.ProtectedData.Unprotect(Byte[] encryptedData, Byte[] optionalEntropy, DataProtectionScope scope) +436

System.IdentityModel.ProtectedDataCookieTransform.Decode(Byte[] encoded) +48

&nbsp;

<span style="background-color: #ffff00">[InvalidOperationException: ID1073: A CryptographicException occurred when attempting to decrypt the cookie using the ProtectedData API (see inner exception for details). If you are using IIS 7.5, this could be due to the loadUserProfile setting on the Application Pool being set to false. ]</span>

System.IdentityModel.ProtectedDataCookieTransform.Decode(Byte[] encoded) +319

System.IdentityModel.Tokens.SessionSecurityTokenHandler.ApplyTransforms(Byte[] cookie, Boolean outbound) +167

System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver) +784

System.IdentityModel.Tokens.SessionSecurityTokenHandler.ReadToken(Byte[] token, SecurityTokenResolver tokenResolver) +88

System.IdentityModel.Services.SessionAuthenticationModule.ReadSessionTokenFromCookie(Byte[] sessionCookie) +512

System.IdentityModel.Services.SessionAuthenticationModule.TryReadSessionTokenFromCookie(SessionSecurityToken&amp; sessionToken) +258

System.IdentityModel.Services.SessionAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs) +143

</div>
&nbsp;

<strong><u>General Approach</u></strong>:

We have a couple of blogs with detailed explanation on this issue and how to resolve it
<ul>
 	<li><span><a href="https://blogs.msdn.microsoft.com/distributedservices/2012/10/29/wif-1-0-id1073-a-cryptographicexception-occurred-when-attempting-to-decrypt-the-cookie-using-the-protecteddata-api/">https://blogs.msdn.microsoft.com/distributedservices/2012/10/29/wif-1-0-id1073-a-cryptographicexception-occurred-when-attempting-to-decrypt-the-cookie-using-the-protecteddata-api/</a></span></li>
 	<li><span><a href="https://blogs.msdn.microsoft.com/napegadie_kones_msft_blog/2016/01/19/cryptographicexception-key-not-valid-for-use-in-specified-state/">https://blogs.msdn.microsoft.com/napegadie_kones_msft_blog/2016/01/19/cryptographicexception-key-not-valid-for-use-in-specified-state/</a></span></li>
</ul>
&nbsp;

This exception usually occurs, when there is a load balancer that routes incoming user requests to one of the servers in a cluster environment.  In other words, the exception will occur if the request gets routed to a different server than the one that served the first request for that session.

&nbsp;

There are three ways to resolve this issue as mentioned in the above blogs:

1- Use sticky sessions at the Load Balancer

2- Use X509 Certificate to secure sessions cookies

3- Use DPAPI with matching machine keys

&nbsp;

<strong><u>Challenges</u></strong>:

In our scenario, enabling sticky sessions will not help. And we don’t want to use certificate since it needs some code changes. We are only left with option 3 where use matching machine keys across the machines in the cluster for encrypting and decrypting session cookies.

&nbsp;

Though we generate machine keys from one IIS machine and copied to all the servers in the load balancer, we might still see it is failing with the same error.

&nbsp;

By adding matching Machines keys to the web.cofig or machine.config will not suffice.

&nbsp;

WIF provides a specialized session token handler, the <a href="https://docs.microsoft.com/en-us/dotnet/api/system.identitymodel.services.tokens.machinekeysessionsecuritytokenhandler">MachineKeySessionSecurityTokenHandler</a>, that protects tokens by using the keys specified in the &lt;machineKey&gt; element.

&nbsp;

Configure your application to use <a href="https://docs.microsoft.com/en-us/dotnet/api/system.identitymodel.services.tokens.machinekeysessionsecuritytokenhandler">MachineKeySessionSecurityTokenHandler</a> by adding it to the token handler collection. Remove  <strong><em><a href="https://docs.microsoft.com/en-us/dotnet/api/system.identitymodel.tokens.sessionsecuritytokenhandler">SessionSecurityTokenHandler</a></em></strong>, and add <strong><em><a href="https://docs.microsoft.com/en-us/dotnet/api/system.identitymodel.services.tokens.machinekeysessionsecuritytokenhandler">MachineKeySessionSecurityTokenHandler</a></em></strong>.

&nbsp;

I added the following in config:
<div style="font-family: Consolas">
<pre>
<span style="color: #0000ff">&lt;</span><span style="color: #993300">securityTokenHandlers</span>&gt;

    <span style="color: #0000ff">&lt;remove</span> <span style="color: #008080">type</span>=<span style="color: #993300">"SessionSecurityTokenHandler"</span><span style="color: #0000ff">/&gt; </span>

    <span style="color: #0000ff">&lt;add</span> <span style="color: #008080">type</span>=<span style="color: #993300">"MachineKeySessionSecurityTokenHandler"</span> <span style="color: #0000ff">/&gt; </span>

<span style="color: #0000ff">&lt;/</span><span style="color: #993300">securityTokenHandlers</span><span style="color: #0000ff">&gt;</span>
</pre>
</div>
&nbsp;

With the above config, ran into configuration errors that it could not find the specified handler, and the site itself doesn’t load.

Then, I modified the config the following way:
<pre>
<span style="color: #993300">&lt;securityTokenHandlers&gt;</span>

 <span style="color: #0000ff">&lt;clear/&gt;</span>

<span style="color: #0000ff">    &lt;remove</span> <span style="color: #008080">type</span>=<span style="color: #993300">"System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"</span> <span style="color: #0000ff">/&gt;</span>

<span style="color: #0000ff">    &lt;add</span> <span style="color: #008080">type</span>=<span style="color: #993300">"System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"</span> <span style="color: #0000ff">/&gt;</span>

<span style="color: #993300">&lt;/securityTokenHandlers&gt;</span>
</pre>
&nbsp;

Then, I ran into the following error:
<div style="font-family: Consolas">

<span style="background-color: #ffff00">ID4014: A SecurityTokenHandler is not registered to read security token ('Assertion', 'urn:oasis:names:tc:SAML:2.0:assertion').</span>

<span style="background-color: #ffff00">Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</span>

Exception Details: System.IdentityModel.Tokens.SecurityTokenException: ID4014: A SecurityTokenHandler is not registered to read security token ('Assertion', 'urn:oasis:names:tc:SAML:2.0:assertion').

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityTokenException: ID4014: A SecurityTokenHandler is not registered to read security token ('Assertion', 'urn:oasis:names:tc:SAML:2.0:assertion').]

System.IdentityModel.Services.TokenReceiver.ReadToken(String tokenXml, XmlDictionaryReaderQuotas readerQuotas, FederationConfiguration federationConfiguration) +440

System.IdentityModel.Services.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequestBase request) +337

System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +467

System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +139

System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195

System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +88

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2623.0

</div>
&nbsp;

<strong><u>Solution</u></strong>:

While I edited the config using visual studio editor, <span style="background-color: #ffff00">&lt;clear/&gt;</span> tag got added within  section. And encountered the above error. Make sure  tag is removed. 

&nbsp;

The right config element that worked is the following:

&nbsp;
<pre>
<span style="color: #993300">&lt;System.IdentityModel&gt;</span>
     <span style="color: #993300">&lt;identityConfiguration&gt;</span>
          <span style="color: #993300">&lt;securityTokenHandlers&gt;</span>
               <span style="color: #0000ff">&lt;remove</span> <span style="color: #008080">type</span>=<span style="color: #993300">"System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"</span> <span style="color: #0000ff">/&gt;</span>
               <span style="color: #0000ff">&lt;add</span> <span style="color: #008080">type</span>=<span style="color: #993300">"System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"</span> <span style="color: #0000ff">/&gt;</span>
          <span style="color: #993300">&lt;/securityTokenHandlers&gt;</span>
     <span style="color: #993300">&lt;/identityConfiguration&gt;</span>
<span style="color: #993300">&lt;/System.IdentityModel&gt;</span>
</pre>
&nbsp;

Hope this helps!]]></content:encoded>
    </item>
    <item>
      <title>WCF: Verbose PII Tracing</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/wcf-verbose-pii-tracing</link>
      <pubDate>Mon, 18 Jun 2018 18:16:15 GMT</pubDate>
      <dc:creator><![CDATA[Saurabh Somani]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=3245</guid>
      <description><![CDATA[WCF PII Verbose tracing
====

Depending on app built, update the machine.config file

Add...]]></description>
      <content:encoded><![CDATA[WCF PII Verbose tracing
====

Depending on app built, update the machine.config file

Add line:
&lt;machineSettings enableLoggingKnownPii="true"/&gt;

&lt;!-- Sample --&gt;
&lt;system.serviceModel&gt;
&lt;machineSettings enableLoggingKnownPii="true"/&gt;

<strong>OUTSIDE &lt;System.ServiceModel&gt; tag add below lines:</strong>

&lt;system.diagnostics&gt;
&lt;sources&gt;
&lt;source logKnownPii="true" name="System.ServiceModel.MessageLogging"
switchValue="Verbose,ActivityTracing"&gt;
&lt;listeners&gt;
&lt;add type="System.Diagnostics.DefaultTraceListener" name="Default"&gt;
&lt;filter type="" /&gt;
&lt;/add&gt;
&lt;add name="ServiceModelMessageLoggingListener"&gt;
&lt;filter type="" /&gt;
&lt;/add&gt;
&lt;/listeners&gt;
&lt;/source&gt;
&lt;source propagateActivity="true" name="System.ServiceModel" switchValue="Verbose,ActivityTracing"&gt;
&lt;listeners&gt;
&lt;add type="System.Diagnostics.DefaultTraceListener" name="Default"&gt;
&lt;filter type="" /&gt;
&lt;/add&gt;
&lt;add name="ServiceModelTraceListener"&gt;
&lt;filter type="" /&gt;
&lt;/add&gt;
&lt;/listeners&gt;
&lt;/source&gt;
&lt;/sources&gt;
&lt;sharedListeners&gt;
&lt;add initializeData="c:\temp\app_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack"&gt;
&lt;filter type="" /&gt;
&lt;/add&gt;
&lt;add initializeData="c:\temp\app_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack"&gt;
&lt;filter type="" /&gt;
&lt;/add&gt;
&lt;/sharedListeners&gt;
&lt;/system.diagnostics&gt;

<strong>INSIDE &lt;System.ServiceModel&gt; tag add below lines:</strong>

&lt;system.serviceModel&gt;
&lt;diagnostics&gt;
&lt;messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /&gt;
&lt;endToEndTracing propagateActivity="true" activityTracing="true"
messageFlowTracing="true" /&gt;
&lt;/diagnostics&gt;

<strong>ONCE DONE, we should see following entry in Event logs</strong>
============
PII logging has been turned on. Sensitive information will be logged in the clear.
Process Name: ConsoleApplication1.vshost
Process ID: 5996

- &lt;Event xmlns="schemas.microsoft.com/win/2004/08/events/event"&gt;
- &lt;System&gt;
&lt;Provider Name="System.ServiceModel 4.0.0.0" /&gt;
&lt;EventID Qualifiers="49153"&gt;107&lt;/EventID&gt;
&lt;Level&gt;4&lt;/Level&gt;
&lt;Task&gt;7&lt;/Task&gt;
&lt;Keywords&gt;0x80000000000000&lt;/Keywords&gt;
&lt;TimeCreated SystemTime="2018-02-06T00:56:31.835601400Z" /&gt;
&lt;EventRecordID&gt;133301&lt;/EventRecordID&gt;
&lt;Channel&gt;Application&lt;/Channel&gt;
&lt;Computer&gt;CC.XX.XXX.XXX&lt;/Computer&gt;
&lt;Security UserID="XXX.XXX" /&gt;
&lt;/System&gt;
- &lt;EventData&gt;
&lt;Data&gt;ConsoleApplication1.vshost&lt;/Data&gt;
&lt;Data&gt;5996&lt;/Data&gt;
&lt;/EventData&gt;
&lt;/Event&gt;

I hope this helps :)

Thanks

SS]]></content:encoded>
    </item>
    <item>
      <title>Difficulties reading PSObject using WCF Message class</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/difficulties-reading-psobject-using-wcf-message-class</link>
      <pubDate>Mon, 07 May 2018 17:40:05 GMT</pubDate>
      <dc:creator><![CDATA[Soni, Rohit]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=3225</guid>
      <description><![CDATA[Issue: We would not be able to deserialize powershell object (PSObject) using WCF Message class...]]></description>
      <content:encoded><![CDATA[<strong>Issue:</strong> We would not be able to deserialize powershell object (PSObject) using WCF Message class directly.

<strong>Error:</strong>

"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter schemas.xyz.com/Services/MyService:DoServiceResult. The InnerException message was 'Member <strong>'CliXml'</strong> was not found.'.".

&nbsp;

<strong>• Cause –</strong>
Failing Message:
&lt;CliXml i:type="d3p1:string" xmlns:d3p1="www.w3.org/2001/XMLSchema"&gt;&amp;lt;Objs Version="1.1.0.1" xmlns="schemas.microsoft.com/powershell/2004/04"&amp;gt;

Working Message:
&lt;CliXml xmlns:d7p1="www.w3.org/2001/XMLSchema" i:type="d7p1:string" xmlns=""&gt;&amp;lt;Objs Version="1.1.0.1" xmlns="schemas.microsoft.com/powershell/2004/04"&amp;gt;

Working message defines the namespace for the <strong>CliXml</strong> element where the failing version does not.

&nbsp;

<strong>• Resolution –</strong>

We added a message inspector on the WCF services (not the client) and inspected the message in BeforeSendReply. It can also be compare by taking a service side WCF traces.

A simple workaround for this is to make a change similar to this:

MessageConverter.cs:

public Message ResponseToMessage(ResponseBase response)
{
try
{
var sb = new StringBuilder();

using (var sw = new StringWriter(sb))
using (var tw = new XmlTextWriter(sw))
{
var serializer = new DataContractSerializer(response.GetType(), BodyInfo.Operation + "Result", String.Empty);
serializer.WriteStartObject(tw, response);

tw.WriteAttributeString("xmlns", "b", null, OperationInfo.Service.Namespaces.Base); // "base" namespace
tw.WriteAttributeString("xmlns", "e", null, OperationInfo.Namespaces.Response ); // "entity" namespace

serializer.WriteObjectContent(tw, response);
serializer.WriteEndObject(tw);
}

var responseBody = String.Format("&lt;{0} xmlns=\"{1}\"&gt;{2}&lt;/{0}&gt;", BodyInfo.Operation + "Response", OperationInfo.Service.Namespaces.Service, sb.ToString());
responseBody = responseBody.Replace("&lt;CliXml ", "&lt;CliXml xmlns=\"\" ");
XmlDocument doc = new XmlDocument();
doc.Load(new StringReader(responseBody));

var responseAction = OperationInfo.Service.Namespaces.ReplyAction + BodyInfo.Operation + "Response";
return Message.CreateMessage(SoapMessage.Version, responseAction, new XmlNodeReader(doc));
}
catch (Exception ex)
{
throw new ApplicationException(String.Format("ResponseToMessage exception: '{0}'!", ex.Message), ex);
}
}

&nbsp;

With this only change on the server side “ServiceHosting”, the “client” is able to read the “PSObject” information de-serialized perfectly fine.

&nbsp;

Rohit Soni (MSFT)]]></content:encoded>
    </item>
    <item>
      <title>AppFabric: Caching service crashed with exception {System.ArgumentException: An entry with the same key already exists.</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/appfabric-caching-service-crashed-with-exception-system-argumentexception-an-entry-with-the-same-key-already-exists</link>
      <pubDate>Mon, 07 May 2018 17:02:07 GMT</pubDate>
      <dc:creator><![CDATA[Soni, Rohit]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=3205</guid>
      <description><![CDATA[Recently we had some cases where AppFabric caching service was crashing with error "An entry with...]]></description>
      <content:encoded><![CDATA[Recently we had some cases where AppFabric caching service was crashing with error "An entry with the same key already exists."

Issue: In the AppFabric event logs (Applications and Services Logs &gt; Microsoft &gt; Windows &gt; Application Server-System Services), we'll see below error logged.

AppFabric Caching service crashed with exception {System.ArgumentException: An entry with the same key already exists.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item)
at System.Collections.Generic.SortedDictionary`2.Add(TKey key, TValue value)
<strong>at Microsoft.Fabric.Data.PartitionTable.UpdateEntry(LookupTableEntry newEntry)</strong>
<strong> at Microsoft.Fabric.Data.PM.PMPartitionTable..ctor(PartitionManager pm, IList`1 partitions, Int64 savedVersion, Object lockObject)</strong>
<strong> at Microsoft.Fabric.Data.PM.PartitionCache..ctor(PartitionManager pm, IPartitionManagerStore pmStore, LoadTable loadTable, IList`1 partitions, Int64 savedLookupVersion)</strong>
<strong> at Microsoft.Fabric.Data.PM.PartitionManager.ProcessLoadPM(Object state)</strong>
at Microsoft.Fabric.Common.IOCompletionPortWorkQueue.Invoke(WaitCallback callback, Object state)
at Microsoft.Fabric.Common.IOCompletionPortWorkQueue.WorkerThreadStart()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()}. Check debug log for more information

&nbsp;

<strong>Reason:</strong> This is happening at PartitionTable.UpdateEntry, which indicates a problem with the cache partitions.

&nbsp;

<strong>Solution:</strong>

We would need to wipe the partitions out and rebuild them.

-- Exported and Imported cache cluster config…
1. Open PowerShell as Administrator.
2. Use-CacheCluster.
3. Export-CacheClusterConfig c:\output.txt
4. Open output.txt with Notepad.
5. Find and replace &lt;dataCache size=”Medium”&gt; to &lt;dataCache size=”Small”&gt;.
6. Find and replace &lt;caches partitionCount=”256″&gt; to &lt;caches partitionCount=”32″&gt;.
7. Save and close output.txt.
8. Go back to PowerShell as Administrator.
9. Run: Stop-CacheCluster to ensure that AppFabric Distributed Cache Service is not running.
10. Run: Import-CacheClusterConfig c:\output.txt.
11. Run: Start-CacheCluster and ensure that all cache hosts are started.
12. Wait a few minutes to allow the cache hosts to start completely.

&nbsp;

Select one of the following three options to optimize performance based on cluster size. This setting is available only if the <strong>New Cluster</strong> control is selected.
<ul>
 	<li class="unordered"><strong>Small [1-5 computers]</strong></li>
 	<li class="unordered"><strong>Medium [6-15 computers]</strong></li>
 	<li class="unordered"><strong>Large [&gt; 15 computers]</strong></li>
</ul>
Reference link: https://msdn.microsoft.com/en-us/library/ff637694%28v=azure.10%29.aspx?f=255&amp;MSPPError=-2147217396

Hope this information helps!

Rohit Soni (MSFT)]]></content:encoded>
    </item>
    <item>
      <title>WCF: Windows authentication and streaming support</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/wcf-windows-authentication-and-streaming-support</link>
      <pubDate>Mon, 16 Apr 2018 16:51:15 GMT</pubDate>
      <dc:creator><![CDATA[Saurabh Somani]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=3175</guid>
      <description><![CDATA[Issue:
We had a requirement to use STREAMING protocol along with WINDOWS AUTHENTICATION.

Out of...]]></description>
      <content:encoded><![CDATA[<strong>Issue:</strong>
We had a requirement to use STREAMING protocol along with WINDOWS AUTHENTICATION.

<strong>Out of the box configuration:</strong>
<a href="https://msdnshared.blob.core.windows.net/media/2018/04/Capture1.png"><img width="322" height="211" class="alignleft size-full wp-image-3185" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/Capture1.png" /></a>

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

Above binding configuration will not help us here and we will end up seeing below error.

<strong>Error Message:</strong>
$exception {"HTTP request streaming cannot be used in conjunction with HTTP authentication. Either disable request streaming or specify anonymous HTTP authentication.\r\nParameter name: bindingElement"} System.ArgumentException
at System.ServiceModel.Channels.HttpChannelFactory`1..ctor(HttpTransportBindingElement bindingElement, BindingContext context)

<strong>ANALYSIS</strong>
As per HttpChannelFactory ctor https://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/Channels/HttpChannelFactory.cs,9739a9339ab039dc it is not allowed.

if (TransferModeHelper.IsRequestStreamed(bindingElement.TransferMode) &amp;&amp; bindingElement.AuthenticationScheme!= AuthenticationSchemes.Anonymous)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("bindingElement", SR.GetString(SR.HttpAuthDoesNotSupportRequestStreaming));
}

<strong>Response from WCF PG:</strong>
The problem is that a stream can't be replayed without buffering.
1. When using authentication, the first request to the server has no authentication and the server will respond with an authentication challenge.
2. WCF uses the Expect 100-Continue header to avoid the request body being sent in the non-authenticated first request.
3. The client then needs to send the request a second time.
4. If there is a very high latency to the server, Expect-100 continue mechanism effectively is disabled. Also, the server might not support the Expect 100-Continue capability.
5. If we need to resend the body, this works fine <em>if the request is buffered. </em>
6. But, we always have a chance if the body needs to be re-sent when using authentication.
This becomes fundamentally incompatible with streamed mode as it is unpredictable whether any one request will succeed.

As for a potential workaround (where performance is a constraint), there are several possibilities, but the simplest is probably to use WebSockets.
With WebSockets, the authentication is done on the HTTP WebSocket upgrade handshake. So, there’s no problem with the payload being part of the authentication conversation. WebSockets can handle streamed mode without any issue.

The binding will be similar to this:
<a href="https://msdnshared.blob.core.windows.net/media/2018/04/Capture11.png"><img width="386" height="219" class="alignleft size-full wp-image-3195" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/Capture11.png" /></a>

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

Hope this information helps!

<em>Content created by:</em>
Nadim Akhtar

<em>Content published by:</em>
Saurabh Somani]]></content:encoded>
    </item>
    <item>
      <title>WIF: Fetch SAML tokens from IssuedToken* endpoint for backend service call</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/wif-fetch-saml-tokens-from-issuedtoken-endpoint-for-backend-service-call</link>
      <pubDate>Thu, 15 Mar 2018 20:18:50 GMT</pubDate>
      <dc:creator><![CDATA[Purna Chandra Panda (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=3065</guid>
      <description><![CDATA[Recently, I have across a scenario where the requirement is to fetch token from "IssuedToken*"...]]></description>
      <content:encoded><![CDATA[Recently, I have across a scenario where the requirement is to fetch token from "IssuedToken*" active ADFS endpoints. Once application has the token from "IssuedToken*" endpoint, it would have to present the token to backend WCF service application operation invokes.

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/overall-architecture.png"><img width="454" height="342" class="aligncenter size-full wp-image-3075" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/overall-architecture.png" /></a>

We went through a lot of hardship to figure out the right binding and ADFS configuration in order to find right solution. Since there is not much public documentation around it, it was a tough goal to achieve.

So, I am just sharing the steps and sample for everyone's benefit.

&nbsp;

The whole next set of steps are written with the assumption that application and RP Trust endpoints would be part of same domain. Towards the end, I would clarify for the two domain scenario.

&nbsp;

<strong><u>Steps for WCF Service Application</u></strong>
<ol type="1">
 	<li value="1"><span>Launch VS 2012 as an administrator, and create a "WCF Service Application".</span></li>
 	<li><span>Make your service ready with business logic.</span></li>
 	<li><span>Right click on the project/ go to </span><b>Properties</b><span>/ go to </span><b>Web</b><span> tab/ </span><b>Create virtual directory</b><span>/ </span><b>Deploy</b><span> to IIS.</span></li>
 	<li><span>Ensure the WCF service is accessible over </span><b>https</b><span>.</span></li>
 	<li><span>Right click on the project, and go to "</span><b>Identity and Access</b><span> tool".</span></li>
 	<li><span>Point to ADFS metadata URL and APP ID URL. </span></li>
</ol>
<a href="https://msdnshared.blob.core.windows.net/media/2018/03/p1.png"><img width="711" height="349" class="aligncenter size-full wp-image-3085" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/p1.png" /></a>
<ol type="1">
 	<li value="7">Let's go to "web.config"</li>
 	<li>Ensure to have the following configuration under System.IdentityModel.</li>
</ol>
<pre>&lt;system.identityModel&gt;
   &lt;identityConfiguration saveBootstrapContext="true"&gt;
   &lt;audienceUris&gt;
       &lt;add value="https://aadconnect.contoso.com/Issuedtokenmixedasymmetricbasic256WcfService1/Service1.svc" /&gt;
       &lt;add value="https://test1.com/"/&gt;
   &lt;/audienceUris&gt;
   &lt;issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry"&gt;
       &lt;authority name="adfs.contoso.com/adfs/services/trust"&gt;
           &lt;keys&gt;
               &lt;add thumbprint="567845870C8A0D9BA17503B3B14EC604B95F41AF" /&gt;
           &lt;/keys&gt;
           &lt;validIssuers&gt;
                &lt;add name="adfs.contoso.com/adfs/services/trust" /&gt;
           &lt;/validIssuers&gt;
       &lt;/authority&gt;
   &lt;/issuerNameRegistry&gt;
   &lt;!--certificationValidationMode set to "None" by the the Identity and Access Tool for Visual Studio. For development purposes.--&gt;
   &lt;certificateValidation certificateValidationMode="None" /&gt;
&lt;/identityConfiguration&gt;
&lt;/system.identityModel&gt;
</pre>
&nbsp;
<ol type="1">
 	<li value="9">Update the System.ServiceModel section with "ws2007FederationHttpBinding" for the WCF service endpoint.</li>
</ol>
<pre>&lt;system.serviceModel&gt;
    &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
            &lt;behavior&gt;
                &lt;!-- To avoid disclosing metadata information, set the values below to false before deployment --&gt;
                &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /&gt;
                &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --&gt;
                &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
                &lt;serviceCredentials useIdentityConfiguration="true"&gt;
                     &lt;!--Certificate added by Identity and Access Tool for Visual Studio.--&gt;
                     &lt;serviceCertificate findValue="CN=localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectDistinguishedName" /&gt;
                &lt;/serviceCredentials&gt;
            &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
     &lt;/behaviors&gt;
     &lt;protocolMapping&gt;
          &lt;add scheme="https" binding="<b>ws2007FederationHttpBinding</b>" /&gt;
     &lt;/protocolMapping&gt;
     &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /&gt;
     &lt;bindings&gt;
<b>     &lt;ws2007FederationHttpBinding&gt;</b>
<b>       &lt;binding&gt;</b>
<b>         &lt;security mode="TransportWithMessageCredential"&gt;</b>
<b>           &lt;message issuedKeyType="BearerKey"&gt;</b>
<b>             &lt;issuerMetadata address="https://adfs.contoso.com/adfs/services/trust/mex" /&gt;</b>
<b>           &lt;/message&gt;</b>
<b>         &lt;/security&gt;</b>
<b>       &lt;/binding&gt;</b>
<b>     &lt;/ws2007FederationHttpBinding&gt;</b>
     &lt;/bindings&gt;
&lt;/system.serviceModel&gt;
</pre>
&nbsp;
<ol type="1">
 	<li value="10">Ensure WCF service URL is accessible over browser, and https.</li>
</ol>
&nbsp;

<strong><u>Steps for ADFS Provisioning</u></strong>

1)

Set up RP Trust with a custom identifier to map the ADFS endpoint '/adfs/services/trust/13/usernamemixed'.

Since it is an active authentication call, there is no need to set up for passive endpoint.

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/kp2.png"><img width="392" height="348" class="aligncenter size-full wp-image-3095" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/kp2.png" /></a>

Ensure you use your "ADFS encryption certificate" to encrypt the payload.

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/kp3.png"><img width="397" height="290" class="aligncenter size-full wp-image-3105" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/kp3.png" /></a>

Set up the claim rule to fetch info from "Active Directory".

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/kp4.png"><img width="531" height="320" class="aligncenter size-full wp-image-3115" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/kp4.png" /></a>

&nbsp;

2)

Set up RP Trust with a custom identifier to map the ADFS endpoint '/adfs/services/trust/13/issuedToken*******'.

Since it is an active authentication call, there is no need to set up for passive endpoint.

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/kp9.png"><img width="442" height="234" class="aligncenter size-full wp-image-3125" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/kp9.png" /></a> <a href="https://msdnshared.blob.core.windows.net/media/2018/03/ep-256.png"><img width="388" height="292" class="aligncenter size-full wp-image-3135" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/ep-256.png" /></a>

Set up the claim rule as the following:

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/kp6.png"><img width="473" height="234" class="aligncenter size-full wp-image-3145" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/kp6.png" /></a>

3)

Set up RP Trust for the WCF service endpoint address.

Since it is an active authentication call, there is no need to set up for passive endpoint.

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/kp7.png"><img width="387" height="283" class="aligncenter size-full wp-image-3155" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/kp7.png" /></a>

&nbsp;

Set the "Encryption" certificate, to help encrypt the payload from the RP Trust endpoint. The certificate used in this case would be the same "localhost" certificate used on the web server, where WCF service application was hosted. I used a self-signed certificate in my case.

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/kp8.png"><img width="385" height="267" class="aligncenter size-full wp-image-3165" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/kp8.png" /></a>

Set up the claim rule like the following for the ADFS RP Trust endpoint.

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/kp9.png"><img width="442" height="234" class="aligncenter size-full wp-image-3125" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/03/kp9.png" /></a>

&nbsp;

<strong><u>Steps for Active client application</u></strong>

Broadly, we have to perform the following steps (in sequence) on the client application:
<ol type="a">
 	<li value="1"><span>Using "UserNameWSTrustBinding", client gets token from "usernamemixed" ADFS endpoint.</span></li>
 	<li><span>Using "IssuedTokenWSTrustBinding", client presents the above token to "issuedtokenmixedsymmetricbasic256" ADFS endpoint, and gets a token in response.</span></li>
 	<li><span>Using "WS2007FederationHttpBinding", the token is presented during the WCF service operation call.</span></li>
</ol>
&nbsp;

So, on the application side, we need to write the following code.
<ol type="1">
 	<li value="1"><span>Create a console application.</span></li>
 	<li><span>"Add service reference" to your WCF service endpoint.</span></li>
 	<li><span>Update your "App.config" with the following appSettings.</span></li>
</ol>
&nbsp;
<pre>&lt;appSettings&gt;
    <span>&lt;add key="usernamemixedEP" value="https://adfs.contoso.com/adfs/services/trust/13/usernamemixed"/&gt;</span>
    <span>&lt;add key="usernamemixedAppliesTo" value="https://Test.com/"/&gt;</span>
    <span>&lt;!-- You can enable any of the following issuedToken based ADFS endpoints. --&gt;</span>
    <span>&lt;!-- </span><a href="https://adfs.contoso.com/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256"><span>https://adfs.contoso.com/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256</span></a><span> --&gt;</span>
    <span>&lt;!-- </span><a href="https://adfs.contoso.com/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256sha256"><span>https://adfs.contoso.com/adfs/services/trust/13/issuedtokenmixedsymmetricbasic256sha256</span></a><span> --&gt;</span>
    <span>&lt;!-- </span><a href="https://adfs.contoso.com/adfs/services/trust/13/issuedtokenmixedasymmetricbasic256"><span>https://adfs.contoso.com/adfs/services/trust/13/issuedtokenmixedasymmetricbasic256</span></a><span> --&gt;</span>
    <span>&lt;!-- </span><a href="https://adfs.contoso.com/adfs/services/trust/13/issuedtokenmixedasymmetricbasic256sha256"><span>https://adfs.contoso.com/adfs/services/trust/13/issuedtokenmixedasymmetricbasic256sha256</span></a><span> --&gt;</span>
    <span>&lt;add key="issuedtokenEP" value="https://adfs.contoso.com/adfs/services/trust/13/issuedtokenmixedasymmetricbasic256"/&gt; </span>
    <span>&lt;add key="issuedtokenAppliesTo" value="https://test1.com/"/&gt;</span>
    <span>&lt;!-- Set false if SAML 2.0 Assertion expected. Otherwise, let it be true. --&gt;</span>
    <span>&lt;add key="saml10TokenType" value="false"/&gt;</span>
    <span>&lt;add key="username" value="JohnAdmin@contoso.com"/&gt;</span>
    <span>&lt;add key="password" value="Password01!"/&gt;</span>
    <span>&lt;add key="serviceEpAddress" value="https://aadconnect.contoso.com/Issuedtokenmixedasymmetricbasic256WcfService1/Service1.svc"/&gt;</span>
&lt;/appSettings&gt;
</pre>
&nbsp;
<ol type="1">
 	<li value="4">The program should be updated with the following source code.</li>
</ol>
&nbsp;
<pre>		    class Program
		    {
		        static void Main(string[] args)
		        {
		            var tokenType = ConfigurationManager.AppSettings["saml10TokenType"].ToString();
		            bool isSAML10Token;
		            Boolean.TryParse(tokenType, out isSAML10Token);
		            if (isSAML10Token)
		            {
		                tokenType = "urn:oasis:names:tc:SAML:1.0:assertion";
		            }
		            else
		            {
		                tokenType = "urn:oasis:names:tc:SAML:2.0:assertion";
		            }
		
		            var usernameToken = GetIdentityProviderToken(tokenType);
		
		            var issuedToken = GetRSTSToken(usernameToken, tokenType);
		
		            var serviceResponse = CallService_IssuedToken(issuedToken);
		
		            Console.WriteLine(serviceResponse);
		            Console.ReadLine();
                        }

		        private static SecurityToken GetIdentityProviderToken(string tokenType)
		        {
		            <span style="background-color: yellow">var binding = new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential);</span>
		
		            var factory = new WSTrustChannelFactory(binding, ConfigurationManager.AppSettings["usernamemixedEP"].ToString())
		            {
		                TrustVersion = TrustVersion.WSTrust13
		            };
		
		            factory.Credentials.UserName.Password = ConfigurationManager.AppSettings["password"].ToString();
		            factory.Credentials.UserName.UserName = ConfigurationManager.AppSettings["username"].ToString();
		            factory.Credentials.SupportInteractive = false;
		            factory.Credentials.UseIdentityConfiguration = true;
		
		            <span style="background-color: yellow">var rst = new RequestSecurityToken
		            {
		                RequestType = "docs.oasis-open.org/ws-sx/ws-trust/200512/Issue",
		                AppliesTo = new EndpointReference(ConfigurationManager.AppSettings["usernamemixedAppliesTo"].ToString()),
		                KeyType = "docs.oasis-open.org/ws-sx/ws-trust/200512/SymmetricKey",
		                TokenType = tokenType
		            };</span>
		
		            var channel = factory.CreateChannel();
		            return channel.Issue(rst);
		        }

      		        private static SecurityToken GetRSTSToken(SecurityToken token, string tokenType)
		        {
		            <span style="background-color: yellow">var binding = new IssuedTokenWSTrustBinding();</span>
		            binding.SecurityMode = SecurityMode.TransportWithMessageCredential;
		
		            var issuredTokenEP = ConfigurationManager.AppSettings["issuedtokenEP"].ToString();
		            if (issuredTokenEP.ToLower().EndsWith("issuedtokenmixedasymmetricbasic256sha256")
		                || issuredTokenEP.ToLower().EndsWith("issuedtokenmixedsymmetricbasic256sha256"))
		            {
		                binding.AlgorithmSuite = SecurityAlgorithmSuite.Basic256Sha256;
		            }
		
		            var factory = new WSTrustChannelFactory(binding, issuredTokenEP);
		            factory.TrustVersion = TrustVersion.WSTrust13;
		            factory.Credentials.SupportInteractive = false;
		            factory.Credentials.UseIdentityConfiguration = true;
		            
		            <span style="background-color: yellow">var rst = new RequestSecurityToken
		            {
		                RequestType = "docs.oasis-open.org/ws-sx/ws-trust/200512/Issue",
		                AppliesTo = new EndpointReference(ConfigurationManager.AppSettings["issuedtokenAppliesTo"].ToString()),
		                KeyType = "docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer",
		                TokenType = tokenType,
		            };</span>
		
		            var channel = factory.CreateChannelWithIssuedToken(token);
		
		            return channel.Issue(rst);
		        }
  
		        private static string CallService_IssuedToken(SecurityToken token)
		        {
		            // Creating the channel and calling it
		            <span style="background-color: yellow">var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
		            binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;</span>
		
		            var serviceEpAddress = ConfigurationManager.AppSettings["serviceEpAddress"].ToString();
		            var factory = new ChannelFactory(binding, new EndpointAddress(serviceEpAddress));
		            
		            // Create a channel
		            <span style="background-color: yellow">IService1 client = factory.CreateChannelWithIssuedToken(token);
		            
		            // Invoke the service operation
		            var response = client.GetData(12);
		            ((IClientChannel)client).Close();</span>
		
		            return response;
		        }		
                     }

</pre>
&nbsp;
<ol type="1">
 	<li value="5">The bindings such as <b>UserNameWSTrustBinding</b> and <b>IssuedTokenWSTrustBinding</b> are part of WIF V1, i.e. <b>Microsoft.IdentityModel</b>. So, the trick is to port the old code in your application explicitly.</li>
 	<li>To keep safe of length of this document, I am not putting the whole code. I would attach the whole source code on OneDrive for reference.</li>
</ol>
&nbsp;

<strong><u>Note</u></strong>
It is just configurable. Change the "appSettings" for appropriate keys to make the code functional.

&nbsp;

<strong><u>Two-domain ADFS configuration</u></strong>
Before you create the claims provider trust, you’ll need the following from the IDP:
- Federation service identifier.  This is also known as the Issuer or entity-Id
- Public key of the token signing certificate

Next,
1. In the ADFS management console, right click on Claims Provider Trusts then click Add Claims Provider Trust
2. At the Welcome page, click Start
3. At the Select Data Source page, select Enter claims provider trust data manually
4. Click Next
5. At the Specify Display Name page, in the Display name enter a name
6. Click Next
7. At the Configure URL page, in the WS-Federation Passive URL enter any URL as long as it’s https.
8. Click Next
9. At the Configure Identifier page, in the Claims provider trust identifier field enter the Identifier (aka entity-ID) of the identity provider (aka claims provider)
10. Click Next
11. At the Configure Certificates page, click Add
12. Select the token signing certificate from the identity provider
13. Click Next
14. At the Ready to Add Trust page, click Next
15. Click Close
16. Set your claim rules.  This can be done now or later

&nbsp;

The full sample application is available on <a target="_blank" href="https://1drv.ms/u/s!Alv-X0SnjgmFhU_2hUilncsyYohD" rel="noopener">OneDrive</a>, and also on <a target="_blank" href="https://github.com/PurnaChandraPanda/Issuedtokenmixedasymmetricbasic256Sample.git" rel="noopener">GitHub</a> (welcome to clone it and play around).

&nbsp;

I hope this helps!]]></content:encoded>
    </item>
    <item>
      <title>WS/WCF: Remove Server Header</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/wswcf-remove-server-header</link>
      <pubDate>Mon, 18 Dec 2017 14:06:47 GMT</pubDate>
      <dc:creator><![CDATA[Saurabh Somani]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=3056</guid>
      <description><![CDATA[Requirement:
Need to suppress all instances of the HTTP ‘Server’ header from all HTTP responses...]]></description>
      <content:encoded><![CDATA[<strong>Requirement:</strong>
Need to suppress all instances of the HTTP ‘Server’ header from all HTTP responses including invalid requests that never even reach the application process.

<strong>Why we need this:</strong>
Exposing Server headers as part of response payload is security vulnerability documented under https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html section 14.38.

<strong>Workaround for Self Host WCF Services:</strong>
Set below registry flag to: <strong>2</strong>
<em>HKLM\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\DisableServerHeader</em>

Setting this to 2 will ensure that self host WCF services no longer sends the SERVER header and thus ensure we are security compliant.
Please note that this disables ALL server headers. 

The default value of 0 enables the header, and the value of 1 disables server header from DRIVER (http.sys), but app can still have headers.


<strong>Workaround for IIS hosted applications</strong>
1. Stop the World Wide Web Publishing Service (if IIS services are not required on the server).
2. If they are required, then we would need to use the IIS URL Rewrite module and delete the server header itself.
Refer: https://blogs.msdn.microsoft.com/varunm/2013/04/23/remove-unwanted-http-response-headers/ 


I hope this helps!


Thanks
Saurabh Somani
]]></content:encoded>
    </item>
    <item>
      <title>WIF: Active authentication against "usernamemixed" ADFS endpoint</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/wif-active-authentication-against-usernamemixed-adfs-endpoint</link>
      <pubDate>Wed, 29 Nov 2017 03:40:51 GMT</pubDate>
      <dc:creator><![CDATA[Purna Chandra Panda (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=2875</guid>
      <description><![CDATA[Scenario
One of my customers recently wanted to help write code/ configuration in the following...]]></description>
      <content:encoded><![CDATA[<u><strong><a href="https://msdnshared.blob.core.windows.net/media/2017/11/p6.png"></a>Scenario</strong></u>
One of my customers recently wanted to help write code/ configuration in the following scenario.

ASP.NET web application and WCF service would be hosted on two different machines (IIS web server). User would access web application. And, it would make an "active authentication" call to "usernamemixed" ADFS endpoint. Once it has the token from ADFS, it would be allowed to make the backend WCF service (without any prompt for username/ password) call.

&nbsp;

<u><strong>Solution</strong></u>

For solution to the above challenge, the following are the steps to be followed (one-by-one).

&nbsp;
<ol>
 	<li>Launch VS 2015 as an administrator</li>
 	<li>Create a new project with "WCF service application" template</li>
 	<li>Let it be named "ActiveScenarioService2015"</li>
 	<li>Modify "Iservice1.cs" to contain the following methods:</li>
</ol>
&nbsp;
<pre>		
		using System.ServiceModel;

		namespace ActiveScenarioService2015
		{
			[ServiceContract]
			public interface IService1
			{
				[OperationContract]
				string GetData(int value);

				[OperationContract]
				string GetClaim();
			}
		}

</pre>
<ol start="5">
 	<li>Modify "Service1.svc.cs" to contain the following code:</li>
</ol>
&nbsp;
<pre>		
		using System.Security.Claims;
		using System.ServiceModel;
		using System.Text;

		namespace ActiveScenarioService2015
		{
			public class Service1 : IService1
			{
				public string GetData(int value)
				{
					return string.Format("You entered: {0}", value);
				}

				public string GetClaim()
				{
					ClaimsPrincipal claimsPrincipal = OperationContext.Current.ClaimsPrincipal;

					StringBuilder builder = new StringBuilder();

					builder.AppendLine(string.Format("User identity: {0}", claimsPrincipal.Identity.Name));
					foreach (var claim in claimsPrincipal.Claims)
					{
						builder.AppendLine(string.Format("Claim Type: {0} Claim Value: {1}", claim.Type, claim.Value));
					}

					return builder.ToString();
				}
			}
		}

</pre>
<ol start="6">
 	<li>Ensure you can build the project fine</li>
 	<li>Add reference to assemblies such as "System.IdentityModel" and "System.IdentityModel.Services"</li>
 	<li>Manage Nuget packages -&gt; find "System.IdentityModel.Tokens.ValidatingIssuerNameRegistry" -&gt; "Install"</li>
 	<li>Modify the "web.config" to contain the following configuration items:</li>
</ol>
<pre>	
	&lt;configuration&gt;
	  <span style="background-color: #ffff00">&lt;configSections&gt;
		&lt;section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
	  &lt;/configSections&gt;</span>
	  &lt;appSettings&gt;
		&lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&gt;
		<span style="background-color: #ffff00">&lt;add key="ida:FederationMetadataLocation" value="https://adfs.contoso.com/federationmetadata/2007-06/federationmetadata.xml" /&gt;
		&lt;add key="ida:ProviderSelection" value="productionSTS" /&gt;</span>
	  &lt;/appSettings&gt;
	  &lt;system.web&gt;
		&lt;compilation debug="true" targetFramework="4.6.1" /&gt;
		&lt;httpRuntime targetFramework="4.6.1"/&gt;
	  &lt;/system.web&gt;
	  &lt;system.serviceModel&gt;
		&lt;behaviors&gt;
		  &lt;serviceBehaviors&gt;
			&lt;behavior&gt;
			  &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/&gt;
			  &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
			  <span style="background-color: #ffff00">&lt;serviceCredentials useIdentityConfiguration="true"&gt;
				&lt;serviceCertificate findValue="<span style="background-color: green">CN=localhost</span>" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectDistinguishedName"/&gt;
			  &lt;/serviceCredentials&gt;</span>
			&lt;/behavior&gt;
		  &lt;/serviceBehaviors&gt;
		&lt;/behaviors&gt;
		<span style="background-color: #ffff00">&lt;protocolMapping&gt;
			&lt;add binding="ws2007FederationHttpBinding" scheme="https" /&gt;
		&lt;/protocolMapping&gt;</span>
		&lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /&gt;
		<span style="background-color: #ffff00">&lt;bindings&gt;
		  &lt;ws2007FederationHttpBinding&gt;
			&lt;binding&gt;
			  &lt;security mode="TransportWithMessageCredential"&gt;
				&lt;message&gt;
				  &lt;issuerMetadata address="https://adfs.contoso.com/adfs/services/trust/mex" /&gt;
				&lt;/message&gt;
			  &lt;/security&gt;
			&lt;/binding&gt;
		  &lt;/ws2007FederationHttpBinding&gt;
		&lt;/bindings&gt;</span>
	  &lt;/system.serviceModel&gt;
	  &lt;system.webServer&gt;
		&lt;modules runAllManagedModulesForAllRequests="true"/&gt;
		<!-- To browse web app root directory during debugging, set the value below to true. Set to false before deployment to avoid disclosing web app folder information. -->
		&lt;directoryBrowse enabled="true"/&gt;
	  &lt;/system.webServer&gt;
	  <span style="background-color: #ffff00">&lt;system.identityModel&gt;
		  &lt;identityConfiguration&gt;
			&lt;audienceUris&gt;
			  &lt;add value="https://win7.contoso.com/ActiveScenarioService2015/Service1.svc" /&gt;
			&lt;/audienceUris&gt;
			&lt;issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry"&gt;
			  &lt;authority name="adfs.contoso.com/adfs/services/trust"&gt;
				&lt;keys&gt;
				  &lt;add thumbprint="<span style="background-color: green">BDF5186BFF80A2BC188508F4EEE0E5737CBCD30E</span>" /&gt;
				&lt;/keys&gt;
				&lt;validIssuers&gt;
				  &lt;add name="adfs.contoso.com/adfs/services/trust" /&gt;
				&lt;/validIssuers&gt;
			  &lt;/authority&gt;
			&lt;/issuerNameRegistry&gt;
			<!--certificationValidationMode set to "None" by the the Identity and Access Tool for Visual Studio. For development purposes.-->
			&lt;certificateValidation certificateValidationMode="None" /&gt;
		&lt;/identityConfiguration&gt;
	  &lt;/system.identityModel&gt;</span>
	&lt;/configuration&gt;
</pre>
<ol start="10">
 	<li>Please note about two applications over here
<ol type="a">
 	<li>"CN=localhost"
<ul>
 	<li>you can launch your certificate store (run -&gt; mmc -&gt; add/ remove snap in/ certificates/ Add .. Select "Computer Account"/ OK</li>
 	<li>you would see a certificate named "localhost" in your "personal" store</li>
 	<li>if not, create a self-signed certificate with "localhost" name form IIS manager</li>
</ul>
</li>
</ol>
</li>
 	<li style="list-style-type: none">
<ol type="a" start="2">
 	<li>"BDF5186BFF80A2BC188508F4EEE0E5737CBCD30E"
<ul>
 	<li>it would be the thumbprint value of your "ADFS signing" certificate</li>
</ul>
</li>
</ol>
</li>
</ol>
<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p1.png"><img width="732" height="494" class="aligncenter size-full wp-image-2895" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p1.png" /></a>

&nbsp;

&nbsp;
<ol start="11">
 	<li>Host the WCF service on IIS</li>
 	<li>One simple method is just to create virtual directory via VS project properties</li>
</ol>
<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p2.png"><img width="1024" height="514" class="aligncenter size-large wp-image-2905" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p2-1024x514.png" /></a>
<ol start="13">
 	<li>Go to IIS Manager/ Create an application pool for "v4.0" .NET framework named as "ActiveScenarioService2015" (for example)</li>
 	<li>Ensure "Load User Profile" set to "true" for the application pool</li>
 	<li>Map the IIS hosted application "ActiveScenarioService2015" to the newly created application pool "ActiveScenarioService2015"</li>
 	<li>Ensure you can browse your service application fine (for example - <a href="https://win7.contoso.com/ActiveScenarioService2015/Service1.svc">https://win7.contoso.com/ActiveScenarioService2015/Service1.svc</a>)</li>
</ol>
&nbsp;
<ol start="17">
 	<li>Next step is to provision the service application on ADFS (in this case - it was 3.0)</li>
 	<li>On the IIS server "win7.conrtoso.com", Right click the "localhost" certificate in store, "All Tasks" -&gt; "Export" .. Without private key -&gt; to a DER encoded binary X.509 certificate (.CER) file</li>
 	<li>Go to your ADFS server, and bring in the ".CER" for being used as "encryption" certificate</li>
 	<li>Ensure ADFS "usernamemixed" endpoint is enabled</li>
 	<li>Add "Relying Party Trust"</li>
</ol>
<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p3.png"><img width="715" height="575" class="aligncenter size-full wp-image-2915" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p3.png" /></a>

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p4.png"><img width="708" height="571" class="aligncenter size-full wp-image-2925" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p4.png" /></a>

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p5.png"><img width="708" height="567" class="aligncenter size-full wp-image-2935" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p5.png" /></a>

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p6.png"><img width="718" height="570" class="aligncenter size-full wp-image-2945" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p6.png" /></a>

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p7.png"><img width="703" height="571" class="aligncenter size-full wp-image-2955" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p7.png" /></a>

&nbsp;

Browse the exported "localhost" certificate (.cer) on ADFS server

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p8.png"><img width="718" height="254" class="aligncenter size-full wp-image-2975" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p8.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2017/11/p71.png"></a>

&nbsp;

Don't select any - because we are using ADFS "usernamemixed" endpoint for user authentication

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p9.png"><img width="720" height="569" class="aligncenter size-full wp-image-2985" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p9.png" /></a>

&nbsp;

Provide "Relying Party" identifier to be the service URL

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p10.png"><img width="708" height="572" class="aligncenter size-full wp-image-2995" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p10.png" /></a>

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p11.png"><img width="711" height="573" class="aligncenter size-full wp-image-3015" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p11.png" /></a>

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p12.png"><img width="711" height="566" class="aligncenter size-full wp-image-3025" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p12.png" /></a>

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p13.png"><img width="715" height="577" class="aligncenter size-full wp-image-3035" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p13.png" /></a>

Finish

&nbsp;

Add Rule

<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p14.png"><img width="544" height="577" class="aligncenter size-full wp-image-3045" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p14.png" /></a>

&nbsp;

OK

&nbsp;

&nbsp;
<ol start="22">
 	<li>Now, "RP Trust" provisioning is over in ADFS</li>
</ol>
&nbsp;
<ol start="23">
 	<li>Next, it is turn of the client side to be ready</li>
</ol>
&nbsp;
<ol start="24">
 	<li>Create an MVC web application project named "ActiveScenarioWebClient" in VS 2015</li>
 	<li>Ensure you can build the web application project fine</li>
 	<li>"Add Service Reference" to the WCF service URL <a href="https://win7.contoso.com/ActiveScenarioService2015/Service1.svc">https://win7.contoso.com/ActiveScenarioService2015/Service1.svc</a></li>
 	<li>Build the project</li>
 	<li>Now, turn to "web.confg" and ensure following sections appended or appeared in <b>&lt;system.serviceModel .. /&gt;</b> section</li>
</ol>
&nbsp;
<pre>  &lt;system.serviceModel&gt;
    &lt;bindings&gt;
      &lt;basicHttpBinding&gt;
        &lt;binding name="BasicHttpBinding_IService1" /&gt;
      &lt;/basicHttpBinding&gt;
      &lt;wsHttpBinding&gt;
        &lt;binding name="https://adfs.contoso.com/adfs/services/trust/2005/certificatemixed"&gt;
          &lt;security mode="TransportWithMessageCredential"&gt;
            &lt;transport clientCredentialType="None" /&gt;
            &lt;message clientCredentialType="Certificate" establishSecurityContext="false" /&gt;
          &lt;/security&gt;
        &lt;/binding&gt;
        <span style="background-color: #ffff00">&lt;binding name="https://adfs.contoso.com/adfs/services/trust/2005/usernamemixed"&gt;
          &lt;security mode="TransportWithMessageCredential"&gt;
            &lt;transport clientCredentialType="None" /&gt;
            &lt;message clientCredentialType="UserName" establishSecurityContext="false" /&gt;
          &lt;/security&gt;
        &lt;/binding&gt;</span>
        &lt;binding name="https://adfs.contoso.com/adfs/services/trust/13/windowstransport"&gt;
          &lt;security mode="Transport" /&gt;
        &lt;/binding&gt;
      &lt;/wsHttpBinding&gt;
      &lt;ws2007HttpBinding&gt;
        &lt;binding name="https://adfs.contoso.com/adfs/services/trust/13/certificatemixed"&gt;
          &lt;security mode="TransportWithMessageCredential"&gt;
            &lt;transport clientCredentialType="None" /&gt;
            &lt;message clientCredentialType="Certificate" establishSecurityContext="false" /&gt;
          &lt;/security&gt;
        &lt;/binding&gt;
        &lt;binding name="https://adfs.contoso.com/adfs/services/trust/13/usernamemixed"&gt;
          &lt;security mode="TransportWithMessageCredential"&gt;
            &lt;transport clientCredentialType="None" /&gt;
            &lt;message clientCredentialType="UserName" establishSecurityContext="false" /&gt;
          &lt;/security&gt;
        &lt;/binding&gt;
      &lt;/ws2007HttpBinding&gt;
      <span style="background-color: #ffff00">&lt;ws2007FederationHttpBinding&gt;
        &lt;binding name="WS2007FederationHttpBinding_IService1_username"&gt;
          &lt;security mode="TransportWithMessageCredential"&gt;
            &lt;message&gt;
              &lt;issuer address="https://adfs.contoso.com/adfs/services/trust/2005/usernamemixed"
                binding="wsHttpBinding" bindingConfiguration="https://adfs.contoso.com/adfs/services/trust/2005/usernamemixed"&gt;
              &lt;/issuer&gt;
              &lt;issuerMetadata address="https://adfs.contoso.com/adfs/services/trust/mex" /&gt;
              &lt;tokenRequestParameters&gt;
                &lt;trust:SecondaryParameters xmlns:trust="docs.oasis-open.org/ws-sx/ws-trust/200512"&gt;
                  &lt;trust:KeyType xmlns:trust="docs.oasis-open.org/ws-sx/ws-trust/200512"&gt;docs.oasis-open.org/ws-sx/ws-trust/200512/SymmetricKey&lt;/trust:KeyType&gt;
                  &lt;trust:KeySize xmlns:trust="docs.oasis-open.org/ws-sx/ws-trust/200512"&gt;256&lt;/trust:KeySize&gt;
                  &lt;trust:KeyWrapAlgorithm xmlns:trust="docs.oasis-open.org/ws-sx/ws-trust/200512"&gt;www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p&lt;/trust:KeyWrapAlgorithm&gt;
                  &lt;trust:EncryptWith xmlns:trust="docs.oasis-open.org/ws-sx/ws-trust/200512"&gt;www.w3.org/2001/04/xmlenc#aes256-cbc&lt;/trust:EncryptWith&gt;
                  &lt;trust:SignWith xmlns:trust="docs.oasis-open.org/ws-sx/ws-trust/200512"&gt;www.w3.org/2000/09/xmldsig#hmac-sha1&lt;/trust:SignWith&gt;
                  &lt;trust:CanonicalizationAlgorithm xmlns:trust="docs.oasis-open.org/ws-sx/ws-trust/200512"&gt;www.w3.org/2001/10/xml-exc-c14n#www.w3.org/2001/04/xmlenc#aes256-cbc&lt;/trust:EncryptionAlgorithm&gt;
                &lt;/trust:SecondaryParameters&gt;
              &lt;/tokenRequestParameters&gt;
            &lt;/message&gt;
          &lt;/security&gt;
        &lt;/binding&gt;
      &lt;/ws2007FederationHttpBinding&gt;</span>
    &lt;/bindings&gt;
    &lt;client&gt;
      &lt;endpoint address="win7.contoso.com/ActiveScenarioService2015/Service1.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
        contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /&gt;
      &lt;endpoint address="https://win7.contoso.com/ActiveScenarioService2015/Service1.svc"
        binding="customBinding" bindingConfiguration="WS2007FederationHttpBinding_IService1"
        contract="ServiceReference1.IService1" name="WS2007FederationHttpBinding_IService1" /&gt;
      <span style="background-color: #ffff00">&lt;endpoint address="https://win7.contoso.com/ActiveScenarioService2015/Service1.svc"
        binding="ws2007FederationHttpBinding" bindingConfiguration="WS2007FederationHttpBinding_IService1_username"
        contract="ServiceReference1.IService1" name="WS2007FederationHttpBinding_IService1_username" /&gt;</span>
    &lt;/client&gt;
  &lt;/system.serviceModel&gt;

</pre>
&nbsp;

&nbsp;
<ol start="29">
 	<li style="list-style-type: none">
<ol start="29">
 	<li>Create a controller named "TestController"</li>
</ol>
</li>
</ol>
<pre>	using ActiveScenarioWebClient.ServiceReference1;
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Web;
	using System.Web.Mvc;

	namespace ActiveScenarioWebClient.Controllers
	{
		public class TestController : Controller
		{
			// GET: Test
			public ActionResult Index()
			{
				<span style="background-color: #ffff00">var proxy = new Service1Client("WS2007FederationHttpBinding_IService1_username");
				proxy.ClientCredentials.UserName.UserName = @"contoso\administrator";
				proxy.ClientCredentials.UserName.Password = "Password01!";
				var response = proxy.GetClaim();</span>
				ViewBag.Response = response;
				proxy.Close();

				return View();
			}
		}
	}
</pre>
<ol start="30">
 	<li style="list-style-type: none">
<ol start="30">
 	<li>Add view "Index.cshtml"</li>
</ol>
</li>
</ol>
<pre>    @{
          ViewBag.Title = "Index";
          }
 
          &lt;h2&gt;Index&lt;/h2&gt;
          &lt;p&gt;@ViewBag.Response&lt;/p&gt;
</pre>
&nbsp;
<ol start="31">
 	<li>Host the web application on IIS</li>
 	<li>Access your web application over browser (e.g. <a href="https://aadconnect.contoso.com/ActiveScenarioWebClient/test">https://aadconnect.contoso.com/ActiveScenarioWebClient/test</a>)</li>
 	<li>The output would be something like</li>
</ol>
<a href="https://msdnshared.blob.core.windows.net/media/2017/11/p15.png"><img width="1024" height="191" class="aligncenter size-large wp-image-3055" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/11/p15-1024x191.png" /></a>
<ol start="34">
 	<li>Once we have this much output, we are good with the authentication flow</li>
</ol>
&nbsp;

<u><strong>Note:</strong></u>

The sample application tried above is up for your reference is available <a href="https://1drv.ms/u/s!Alv-X0SnjgmFhTsDrx45R_IGAZ7D">here</a>. Please launch the VS solution as an administrator to view the sample application.

&nbsp;

&nbsp;

I hope this helps!

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Recovering COM+ Applications from a hang state</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/recovering-com-applications-from-a-hang-state</link>
      <pubDate>Tue, 24 Oct 2017 14:39:55 GMT</pubDate>
      <dc:creator><![CDATA[Purna Chandra Panda (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=2855</guid>
      <description><![CDATA[Recently, I worked with some customer problems where they encountered issues with COM+ application...]]></description>
      <content:encoded><![CDATA[Recently, I worked with some customer problems where they encountered issues with COM+ application going into a hang state. This causes sometimes the main applications to wait indefinitely without recovering from the problem.

In such circumstances, many users/developers of the com+ application manually check the state of the com+ application in the component services page and then they will kill the com+ surrogate process to recover from the situation.

However, this manual recovery method is a tedious process and it cannot be easily handled when there are multiple com+ application in some large-scale enterprises.

<strong>Solution/Workaround</strong>

To automatically recover from these situations, you can configure the system to perform the following actions when a long-running COM+ component is detected. The problem can be solved in one of the two following ways, depending on the requirements of your application and server:

<strong>1. To Change Global COM+ behavior</strong>

To do this, use the following registry values:

In the registry path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\COM3\AutoDump (Please create the keys if it does not exist), add the following keys and their corresponding values:

Key Value name: AverageCallThreshold

Data type: REG_DWORD

Value: Set to 3000 - this is maximum allowed duration of process execution, in seconds. If it is exceeded, a warning is raised.

Key Value name: Terminate

Data type: REG_DWORD

Value: Set to 1 - Process will be terminated on exceeding the maximum call threshold value which is configured above.

Key Value name : DumpType

Data type : REG_DWORD

Value: set to 2- No dump file will be generated. You can set the value as 0 if you want to generate a full dump file or set it to 1 for minidump file.

<b>2. </b><strong>To Modify behavior of a specific COM+ application</strong>

In order to change the behavior of a specific COM+ application, instead of making a global server-wide change, create the above keys (AverageCallThreshold, Terminate and DumpType) and values in the following registry path:

HKEY_CLASSES_ROOT\AppId\{&lt;YourAppID&gt;}\AutoDump\{&lt;YourCLSID&gt;}.

&nbsp;

<strong>Reference Articles</strong>

<a href="https://support.microsoft.com/en-in/kb/910904">https://support.microsoft.com/en-in/kb/910904</a>

Created By

Sakthivel Ramasamy

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>AF: AppFabric Invalid Version Error</title>
      <link>https://docs.microsoft.com/archive/blogs/dsnotes/af-appfabric-invalid-version-error</link>
      <pubDate>Thu, 19 Oct 2017 22:12:27 GMT</pubDate>
      <dc:creator><![CDATA[Purna Chandra Panda (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dsnotes/?p=2836</guid>
      <description><![CDATA[On a clustered environment when you try to start the AppFabric caching service you may encounter the...]]></description>
      <content:encoded><![CDATA[On a clustered environment when you try to start the AppFabric caching service you may encounter the error <em>AppFabric Invalid Version Error. </em>

You will see the following exception logged in the AppFabric event logs

<em>AppFabric Caching service crashed with exception {Microsoft.ApplicationServer.Caching.DataCacheException: ErrorCode&lt;ERRService0001&gt;:SubStatus&lt;ES0001&gt;:Service initialization failed. No user action required. ---&gt; Microsoft.Fabric.Common.OperationCompletedException: Operation completed with an exception ---&gt; Microsoft.Fabric.Federation.InvalidVersionException: Node with version: Microsoft.ApplicationServer.Caching.ServerVersionInfo received an abort because of invalid version</em>

You can use the <strong>Get-CacheHost</strong> command to view the version of the Caching Service on each cache host

The following is the output of the <strong>Get-CacheHost</strong> command executed on a clustered environment.
<table width="531" border="1">
<tbody>
<tr>
<td width="160"><strong>HostName : CachePort</strong></td>
<td width="165"><strong>Service Name</strong></td>
<td width="108"><strong>Service Status</strong></td>
<td width="98"><strong>Version Info</strong></td>
</tr>
<tr>
<td>CACHESERVER1:22233</td>
<td>AppFabricCachingService</td>
<td>UP</td>
<td>3 [3,3][1,3]</td>
</tr>
<tr>
<td>CACHESERVER2:22233</td>
<td>AppFabricCachingService</td>
<td>UP</td>
<td>3 [3,3][1,3]</td>
</tr>
<tr>
<td>CACHESERVER3:22233</td>
<td>AppFabricCachingService</td>
<td>DOWN</td>
<td>3 [1,3][1,1]</td>
</tr>
<tr>
<td>CACHESERVER4:22233</td>
<td>AppFabricCachingService</td>
<td>DOWN</td>
<td>3 [1,3][1,1]</td>
</tr>
</tbody>
</table>
&nbsp;

The Version Info column in this example contains the value 3 [3,3][1,3]. This corresponds to the following version details:
<table border="1">
<tbody>
<tr>
<td><strong> </strong>3</td>
<td>The version of the Caching Service running on that cache host.</td>
</tr>
<tr>
<td>[3,3]</td>
<td>The range of caching service versions that can run on that particular host within the cache cluster during the online upgrade.</td>
</tr>
<tr>
<td>[1,3]</td>
<td>The range of cache client versions that can use the cache cluster.</td>
</tr>
</tbody>
</table>
&nbsp;

The hosts are running the updated Caching Service with a version of 3. But if we look at the allowed server and client versions there is a mismatch on the server instance CACHESERVER3 and CACHESERVER4.

Use <strong>Update-CacheHostAllowedVersions</strong> to update the allowed server and client server versions

Below is the command to update the server and client version range.

<strong>Update-CacheHostAllowedVersions -BeginServerVersion 3</strong>

<strong>Update-CacheHostAllowedVersions -EndClientVersion 3</strong>

&nbsp;

After updating the versions, the caching service started without any issues. The following is the output of the <strong>Get-CacheHost </strong>command<strong>.</strong>

&nbsp;
<table width="531" border="1">
<tbody>
<tr>
<td width="160"><strong>HostName : CachePort</strong></td>
<td width="165"><strong>Service Name</strong></td>
<td width="108"><strong>Service Status</strong></td>
<td width="98"><strong>Version Info</strong></td>
</tr>
<tr>
<td>CACHESERVER1:22233</td>
<td>AppFabricCachingService</td>
<td>UP</td>
<td>3 [3,3][1,3]</td>
</tr>
<tr>
<td>CACHESERVER2:22233</td>
<td>AppFabricCachingService</td>
<td>UP</td>
<td>3 [3,3][1,3]</td>
</tr>
<tr>
<td>CACHESERVER3:22233</td>
<td>AppFabricCachingService</td>
<td>UP</td>
<td>3 [3,3][1,3]</td>
</tr>
<tr>
<td>CACHESERVER4:22233</td>
<td>AppFabricCachingService</td>
<td>UP</td>
<td>3 [3,3][1,3]</td>
</tr>
</tbody>
</table>
&nbsp;

<strong>Reference Articles</strong>

<a href="https://msdn.microsoft.com/en-us/library/hh343304(v=azure.10).aspx">https://msdn.microsoft.com/en-us/library/hh343304(v=azure.10).aspx</a>

&nbsp;

Created by

Sakthivel Ramasamy]]></content:encoded>
    </item>
  </channel>
</rss>