<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Sajay : WinFX</title><link>http://blogs.msdn.com/sajay/archive/tags/WinFX/default.aspx</link><description>Tags: WinFX</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Musings on Workflow Terminated and Exception Handling</title><link>http://blogs.msdn.com/sajay/archive/2007/05/02/musings-on-workflow-termintated-and-exception-handling.aspx</link><pubDate>Wed, 02 May 2007 07:29:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2368278</guid><dc:creator>Sajay</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/sajay/comments/2368278.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sajay/commentrss.aspx?PostID=2368278</wfw:commentRss><description>&lt;p&gt;When a workflow runs an activity and that activity throws some kind of unhandled exception you would notice that your workflow get terminated. I have see in many articles that explain how the termination happens. Now this is fine only for a rare set of hello world scenarios. When it comes to an enterprise application we usually expect to notify that some error has happened and probably redo our work. &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now if the workflow terminates how the heck are we supposed to re-execute the workflow cause its already terminated right :) and you get the "Workflow not found in persistence store" when you use&amp;nbsp;&amp;nbsp;a store like SQL . Now this happens when our activity doesn't have a fault handler associated with this it. So one of the solutions we tried for state machine error handling was this. &lt;/p&gt; &lt;ol&gt; &lt;li&gt;View the FaultHandlers in the event driven activity in the state.  &lt;li&gt;Add a new Fault activity and set the fault type to System.Exception (this is to capture generic faults and nothing fancier) you can customize this but then again we are trying to avoid workflow termination here.  &lt;li&gt;in the fault handler use a CallExternalMethodActivity.  &lt;li&gt;How to catch the exception - You can promote the Fault property as a dependency property. Another easy way would be to call a methodInvoked(ie the method to be executed before the callExternal method is invoked) and in that access the exception as the fault property in the parent of the callExternalMethodActivity.  &lt;li&gt;You can then pass on what ever data you get to the external method. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;I believe there are many more ways of fault handling. I even know of cases where customers hacked the stored procedure of Insertworkflow to avoid workflow deletion on termination. &lt;/p&gt; &lt;p&gt;Anyway this is just on of the easier ways out to clean up incase you have better practices do leave a link :)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2368278" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sajay/archive/tags/WinFX/default.aspx">WinFX</category></item><item><title>Durable Tokens Across Services - Share your tokens</title><link>http://blogs.msdn.com/sajay/archive/2007/04/20/durable-tokens-across-services-share-your-tokens.aspx</link><pubDate>Fri, 20 Apr 2007 09:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2203174</guid><dc:creator>Sajay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sajay/comments/2203174.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sajay/commentrss.aspx?PostID=2203174</wfw:commentRss><description>&lt;p&gt;There seems to be quite a number of time when you want to perform your authentication once and then you just go ahead the want to just call a service without performing the authentication again. &lt;/p&gt; &lt;p&gt;&lt;br&gt;What are some advantages of this ?&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;1. You get to manage your authentication independently. - Also results in a single point of failure. &lt;/p&gt; &lt;p&gt;2. You can build&amp;nbsp;solutions that can leverage an existing authentication framework and save time building that&lt;/p&gt; &lt;p&gt;3. You could have many services talk to each other and share credentials across and build connected systems as they don't have to manager user bases or authentication stores independently. Still there are dependency on user details but the application is freed from worrying about the actual authentication scheme. &lt;/p&gt; &lt;p&gt;4. And many more depending on your scenario :)&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;The SDK already has a DurableTokenSecurity Sample and in this post the only modification to that is the way the token cache is built on the client side. If you haven't yet understood the sample, then the you need to understand how the token is picked up and cached and replayed back. &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Understanding Durable Tokens&lt;/strong&gt; &lt;/p&gt; &lt;p&gt;The endpoint has a ClientCredentials behavior. You have to remove the default behavior and slap on your own. the client credentials is also responsible for retrieving the credentials for a service and sending it out with the service request. &lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;factory.Endpoint.Behaviors.Remove&amp;lt;ClientCredentials&amp;gt;();&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;factory.Endpoint.Behaviors.Add(durableCreds);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;The durable credential extends the &lt;strong&gt;ClientCredentials &lt;/strong&gt;and has a reference to the cache that supplies the tokens and stores the token. The SDK sample comes with multiple forms of cache. A file cache and in memory cache. You can choose what cache you would like as they have the separate uses. &lt;/p&gt; &lt;p&gt;Next step would be to understand how the cache is used. The &lt;strong&gt;DurableIssuedSecurityTokenProvider&amp;nbsp;&lt;/strong&gt;implements&amp;nbsp;the SecurityTokenProvider which is responsible for retrieving the token from the cache and uses the instance of the cache that is provided and calls the Add or TryGet that queries the concrete implementation of the cache. The GetTokenCore is what is used to retrieve the token from the cache. &lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;protected override SecurityToken GetTokenCore(TimeSpan timeout)&lt;/font&gt;&lt;br&gt;&lt;/p&gt; &lt;p&gt;On walking through the implementation of the cache you see that the cache add or removes the tokens and the key is what governs how the tokens are retrieved. In the actual sample the key is is qualified as shown. &lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;Key key = new Key(target.Uri, (issuer == null) ? null : issuer.Uri);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;and when the URI is used. &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Changes to the Cache to share the Tokens across Multiple Service &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Changing the key pretty much increases or changes the total scope of the token. if you changed the key to something like this &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;Key key = new Key(new Uri(target.Uri.GetLeftPart(UriPartial.Authority)),&lt;br&gt;(issuer == null) ? null : issuer.Uri);&lt;/font&gt;  &lt;p&gt;This pretty much says that the same token can be used across multiple services with the same Authority(usually the domain name in this case). &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So there we go we have increased the scope and in this case but you can write your own key building logic and even use something like a predefined list of keys to retrieve the tokens and share them across multiple services. &lt;/p&gt; &lt;p&gt;&lt;br&gt;Check out the source attached and let me know in case you have some queries around this. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2203174" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/sajay/attachment/2203174.ashx" length="313042" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/sajay/archive/tags/WS-_2A00_+and+WCF/default.aspx">WS-* and WCF</category><category domain="http://blogs.msdn.com/sajay/archive/tags/WinFX/default.aspx">WinFX</category></item><item><title>ServiceAuthorizationManager and PrincipalPermission</title><link>http://blogs.msdn.com/sajay/archive/2006/12/22/serviceauthorizationmanager-and-principalpermission.aspx</link><pubDate>Fri, 22 Dec 2006 06:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1344581</guid><dc:creator>Sajay</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sajay/comments/1344581.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sajay/commentrss.aspx?PostID=1344581</wfw:commentRss><description>&lt;p&gt;You may face a problem when trying to check for Principal permission and demand in the CheckAccessCore of the SerivceAuthorizationManager and you might see a security exception. This is primarily because the threads principal is not set when this demand check in the SAM happens. &lt;/p&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can however do a Principal Permission check within the operation either by a Demand() operation for the principal or delcaratively in code. This what Brent Schmaltz who helped with this issue said.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"There are two advantages of the SAM approach it is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;centralized and every call will be routed through there.&amp;nbsp; This avoids what I like to call the ‘fractured policy system” where one needs to touch all access points to understand the authorization policy.&amp;nbsp; This is similar to the File System.&amp;nbsp; For example with this method it is difficult to answer:&amp;nbsp; Can X access Y, without having X attempt to access Y? 
&lt;/li&gt;&lt;li&gt;called way up the stack and is hence has a performance advantage."&lt;/li&gt;&lt;/ol&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;i&gt;&lt;/i&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The solutions was to check the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.identitymodel.claims.windowsclaimset.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.identitymodel.claims.windowsclaimset.aspx"&gt;WindowsClaimSet&lt;/a&gt;. This claim set holds all the SIDs that is required and we can check the claim set if the SID of the group you require exits and bump the user out and authorizer the user using this. Basically you have a collection of &lt;a href="http://msdn2.microsoft.com/en-us/library/system.security.principal.securityidentifier.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.security.principal.securityidentifier.aspx"&gt;SecurityIdentifier&lt;/a&gt;s in the WindowsClaimSet. &lt;/p&gt;
&lt;p&gt;&lt;i&gt;Next time - &lt;a href="http://blogs.msdn.com/sajay/archive/2006/12/27/checking-the-sid-s-in-the-windowsclaimset.aspx" mce_href="http://blogs.msdn.com/sajay/archive/2006/12/27/checking-the-sid-s-in-the-windowsclaimset.aspx"&gt;Checking SID's in the WindowsClaimSet&lt;/a&gt;&lt;/i&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1344581" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sajay/archive/tags/WS-_2A00_+and+WCF/default.aspx">WS-* and WCF</category><category domain="http://blogs.msdn.com/sajay/archive/tags/WinFX/default.aspx">WinFX</category></item><item><title>WSE Client - WCF service Interop</title><link>http://blogs.msdn.com/sajay/archive/2006/05/31/611491.aspx</link><pubDate>Wed, 31 May 2006 11:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:611491</guid><dc:creator>Sajay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sajay/comments/611491.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sajay/commentrss.aspx?PostID=611491</wfw:commentRss><description>&lt;P&gt;I wanted to put up this sample using the Feb CTP. &lt;BR&gt;Basically it uses WSE 3.0 and WCF to demostrate both AnonymousCertificate configuration and MutualCertificate configuration using the service custom binding Configuration and the WSE policy file. &lt;/P&gt;
&lt;P&gt;The point is that WSE uses &lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: teal"&gt;MessageVersion&lt;/SPAN&gt;.Soap11WSAddressingAugust2004 or &lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;MessageVersion&lt;/SPAN&gt;&lt;/FONT&gt;.Soap12WSAddressingAugust2004 &lt;/FONT&gt;&lt;/FONT&gt;basically will need a custom binding for this.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=611491" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/sajay/attachment/611491.ashx" length="33209" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/sajay/archive/tags/WS-_2A00_+and+WCF/default.aspx">WS-* and WCF</category><category domain="http://blogs.msdn.com/sajay/archive/tags/WinFX/default.aspx">WinFX</category></item><item><title>Security at both Message and Transport Level</title><link>http://blogs.msdn.com/sajay/archive/2006/05/24/605648.aspx</link><pubDate>Wed, 24 May 2006 08:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:605648</guid><dc:creator>Sajay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sajay/comments/605648.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sajay/commentrss.aspx?PostID=605648</wfw:commentRss><description>&lt;P&gt;When using webservices we usually want the messages encrypted and also use SSL. This configuration as of now is not supported out of the box. We could use either tranport or message or a type called TransportWithMessageCredentials. &lt;BR&gt;The 3rd type does not encrypt the soap message at the Message level but only supplies the claims(credentials) at this level. The security is pretty much provided at the Transport Level as the name should suggest. &lt;BR&gt;The only binding that provides this out of the box is the following &lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana color=#800000 size=2&gt;netMsmqBinding&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;binding&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;test&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;security&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;mode&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Both&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;security&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;binding&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;netMsmqBinding&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;WsHttpBinding provides a mixed mode but not both.&lt;BR&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT face="Times New Roman" color=#000000 size=3&gt;You can get a full listing here &lt;A href="http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/wcf_con/html/2c243746-45ce-4588-995e-c17126a579a6.asp" target=_blank&gt;Predefined Bindings&lt;/A&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT face="Times New Roman" color=#000000 size=3&gt;Incase you do want to use this you have to create a custom binding specifying each element. The behavior element can be used to specify the credentials that the message level security would use and the tranport can use say the server certificate from IIS. The snippet below shows a bare skeleton of this kind of binding. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana color=#800000 size=2&gt;customBinding&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;binding&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Binding1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;security&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;authenticationMode&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SecureConversation&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; requireSecurityContextCancellation&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;security&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;textMessageEncoding&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;messageVersion&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Soap12WSAddressing10&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;writeEncoding&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;utf-8&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;httpsTransport&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;binding&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;customBinding&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Verdana&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=605648" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sajay/archive/tags/WS-_2A00_+and+WCF/default.aspx">WS-* and WCF</category><category domain="http://blogs.msdn.com/sajay/archive/tags/WinFX/default.aspx">WinFX</category></item><item><title>Getting the X509Certificate Serial Number out of the ClaimSet</title><link>http://blogs.msdn.com/sajay/archive/2006/03/31/565746.aspx</link><pubDate>Fri, 31 Mar 2006 12:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:565746</guid><dc:creator>Sajay</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sajay/comments/565746.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sajay/commentrss.aspx?PostID=565746</wfw:commentRss><description>&lt;P&gt;The ClaimSet is quite interesting and extracting the Serial number from the certificate was something that wasn't that straight forward using &lt;A href="http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref11/html/M_System_IdentityModel_Claims_ClaimSet_FindClaims_1_d460c748.asp"&gt;FindClaims&lt;/A&gt; which takes the ClaimType Enumerator.&amp;nbsp;For this you can cast the claim set into a &lt;SPAN style="COLOR: teal"&gt;&lt;FONT face="Courier New" size=2&gt;X509CertificateClaimSet&lt;/FONT&gt;&lt;/SPAN&gt; and get the Serial Number&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;&lt;/FONT&gt; GetCertificateSerialNumber()&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt;&lt;/FONT&gt; (&lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;ClaimSet&lt;/SPAN&gt;&lt;/FONT&gt; cs &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;OperationContext&lt;/SPAN&gt;&lt;/FONT&gt;.Current.ServiceSecurityContext.AuthorizationContext.ClaimSets)&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt;&lt;/FONT&gt; (cs &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;is&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;X509CertificateClaimSet&lt;/SPAN&gt;&lt;/FONT&gt;)&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt;&lt;/FONT&gt; ((&lt;FONT color=teal&gt;&lt;SPAN style="COLOR: teal"&gt;X509CertificateClaimSet&lt;/SPAN&gt;&lt;/FONT&gt;)cs).SerialNumber;&lt;BR&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/FONT&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color=blue&gt;&lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;&lt;/FONT&gt;;&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=565746" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sajay/archive/tags/WS-_2A00_+and+WCF/default.aspx">WS-* and WCF</category><category domain="http://blogs.msdn.com/sajay/archive/tags/WinFX/default.aspx">WinFX</category></item><item><title>Script for setting up Certificates for WCF</title><link>http://blogs.msdn.com/sajay/archive/2006/03/30/564788.aspx</link><pubDate>Thu, 30 Mar 2006 16:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:564788</guid><dc:creator>Sajay</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sajay/comments/564788.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sajay/commentrss.aspx?PostID=564788</wfw:commentRss><description>&lt;P&gt;I thought this script might be quite useful to set up certificates for testing with services hosted in IIS. This uses 3 tools present in the SDK folder. &lt;BR&gt;1. makecert&lt;BR&gt;2. certmgr&lt;BR&gt;3. FindPrivateKey&lt;BR&gt;You can find these in the WCF samples.&lt;BR&gt;&lt;BR&gt;&lt;EM&gt;Note: Make sure you run this from the Windows SDK prompt and check the cert stores for the certifcates.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;--------------------------------Setup.bat----------------------------&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;echo off&lt;BR&gt;echo ************&lt;BR&gt;echo Client cert setup starting&lt;BR&gt;echo ************&lt;BR&gt;set CLIENT_NAME=client.com&lt;BR&gt;set SERVER_NAME=localhost&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;echo ****************&lt;BR&gt;echo Cleanup starting&lt;BR&gt;echo ****************&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;echo -------------------------&lt;BR&gt;echo del client certs&lt;BR&gt;echo -------------------------&lt;BR&gt;certmgr -del -r CurrentUser -s My -c -n %CLIENT_NAME%&lt;BR&gt;certmgr -del -r CurrentUser -s TrustedPeople -c -n %SERVER_NAME%&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;echo -------------------------&lt;BR&gt;echo del service certs&lt;BR&gt;echo -------------------------&lt;BR&gt;certmgr -del -r LocalMachine -s My -c -n %SERVER_NAME%&lt;BR&gt;certmgr -del -r LocalMachine -s TrustedPeople -c -n %CLIENT_NAME%&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;echo *****************&lt;BR&gt;echo Cleanup completed&lt;BR&gt;echo *****************&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;FONT size=2&gt;echo ************&lt;BR&gt;echo making client cert&lt;BR&gt;echo ************&lt;BR&gt;makecert.exe -sr CurrentUser -ss MY -a sha1 -n CN=%CLIENT_NAME% -sky exchange -pe&lt;BR&gt;echo ************&lt;BR&gt;echo copying client cert to server's CurrentUserstore&lt;BR&gt;echo ************&lt;BR&gt;certmgr.exe -add -r CurrentUser -s My -c -n %CLIENT_NAME% -r LocalMachine -s TrustedPeople&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;FONT size=2&gt;echo ************&lt;BR&gt;echo Server cert setup starting&lt;BR&gt;echo %SERVER_NAME%&lt;BR&gt;echo ************&lt;BR&gt;echo making server cert&lt;BR&gt;echo ************&lt;BR&gt;makecert.exe -sr LocalMachine -ss MY -a sha1 -n CN=%SERVER_NAME% -sky exchange -pe&lt;BR&gt;echo ************&lt;BR&gt;echo copying server cert to client's CurrentUser store&lt;BR&gt;echo ************&lt;BR&gt;certmgr.exe -add -r LocalMachine -s My -c -n %SERVER_NAME% -r CurrentUser -s TrustedPeople&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;FONT size=2&gt;echo ************&lt;BR&gt;echo setting privileges on server certificates&lt;BR&gt;echo ************&lt;BR&gt;for /F "delims=" %%i in ('"FindPrivateKey.exe" My LocalMachine -n CN^=%SERVER_NAME% -a') do set PRIVATE_KEY_FILE=%%i&lt;BR&gt;set WP_ACCOUNT=NT AUTHORITY\NETWORK SERVICE&lt;BR&gt;(ver | findstr "5.1") &amp;amp;&amp;amp; set WP_ACCOUNT=%COMPUTERNAME%\ASPNET&lt;BR&gt;echo Y|cacls.exe "%PRIVATE_KEY_FILE%" /E /G "%WP_ACCOUNT%":R&lt;BR&gt;iisreset&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=564788" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sajay/archive/tags/WS-_2A00_+and+WCF/default.aspx">WS-* and WCF</category><category domain="http://blogs.msdn.com/sajay/archive/tags/WinFX/default.aspx">WinFX</category></item></channel></rss>