{"id":11531,"date":"2016-09-20T13:14:28","date_gmt":"2016-09-20T18:14:28","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=11531"},"modified":"2022-03-09T16:07:03","modified_gmt":"2022-03-09T21:07:03","slug":"secure-asp-net-4-5-with-adfs-2-0","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=11531","title":{"rendered":"Secure ASP.Net 4.5 with ADFS 2.0"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Introduction\">Introduction<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Generate_Initial_Web.config\">Generate Initial Web.config<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Find_Issuer_Name\">Find Issuer Name<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Find_Issuer_Thumbprint\">Find Issuer Thumbprint<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Final_Web.config\">Final Web.config<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Example_Web.config\">Example Web.config<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Example_Code\">Example Code<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Create_Relying_Party\">Create Relying Party<\/a>\n\t\t<ol class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Add_Claim_Rules\">Add Claim Rules<\/a>\n\t\t\t<\/li>\n\t\t<\/ol>\n\t<li>\n\t\t<a href=\"#Deploy_ASP.Net_4.5_to_IIS_7.5\">Deploy ASP.Net 4.5 to IIS 7.5<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Test\">Test<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Introduction\"><h2>Introduction<\/h2><\/span>\n<p>* ASP.Net 4.5 web application can be secured with ADFS 2.0<br \/>\n* Authentication configuration is done in <em>Web.config<\/em> file<\/p>\n<span id=\"Generate_Initial_Web.config\"><h2>Generate Initial Web.config<\/h2><\/span>\n<p>* Use Visual Studio to generate an initial Web.config by pointing to ADFS Federation Metadata URL.<\/p>\n<span id=\"\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_1.jpg\" rel=\"attachment wp-att-11557\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_1.jpg\" alt=\"adfsaspnet1_newsln_1\" width=\"944\" height=\"653\" class=\"aligncenter size-full wp-image-11557\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_1.jpg 944w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_1-300x208.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_1-768x531.jpg 768w\" sizes=\"auto, (max-width: 944px) 100vw, 944px\" \/><\/a><\/h6><\/span>\n<p>* Click <em>Change Authentication<\/em> button:<\/p>\n<span id=\"_1\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_Auth_1.jpg\" rel=\"attachment wp-att-11558\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_Auth_1.jpg\" alt=\"adfsaspnet1_newsln_auth_1\" width=\"761\" height=\"566\" class=\"aligncenter size-full wp-image-11558\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_Auth_1.jpg 761w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_Auth_1-300x223.jpg 300w\" sizes=\"auto, (max-width: 761px) 100vw, 761px\" \/><\/a><\/h6><\/span>\n<p>* Enter ADFS federation metadata URL into <em>On-Premises Authority<\/em> field.<\/p>\n<span id=\"_2\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_Auth_2.jpg\" rel=\"attachment wp-att-11559\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_Auth_2.jpg\" alt=\"adfsaspnet1_newsln_auth_2\" width=\"709\" height=\"300\" class=\"aligncenter size-full wp-image-11559\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_Auth_2.jpg 709w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_NewSln_Auth_2-300x127.jpg 300w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/a><\/h6><\/span>\n<p>* Click OK buttons to create the initial web application<br \/>\n* Relevant elements in the initial <em>Web.config<\/em> file:<\/p>\n<pre lang=\"xml\">\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<configuration>\r\n  <configSections>\r\n    <section name=\"system.identityModel\" type=\"System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\" \/>\r\n    <section name=\"system.identityModel.services\" type=\"System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\" \/>\r\n  <\/configSections>\r\n  <appSettings>\r\n    <add key=\"ida:FederationMetadataLocation\" value=\"https:\/\/sts.my.com\/federationmetadata\/2007-06\/federationmetadata.xml\" \/>\r\n    <add key=\"ida:Realm\" value=\"https:\/\/localhost:44304\/\" \/>\r\n    <add key=\"ida:AudienceUri\" value=\"https:\/\/localhost:44304\/\" \/>\r\n  <\/appSettings>\r\n  <system.web>\r\n    <authentication mode=\"None\" \/>\r\n    <authorization>\r\n      <deny users=\"?\" \/>\r\n    <\/authorization>\r\n    <compilation debug=\"true\" targetFramework=\"4.5\" \/>\r\n    <httpRuntime targetFramework=\"4.5\" requestValidationMode=\"4.5\" \/>\r\n  <\/system.web>\r\n  <system.webServer>\r\n    <modules>\r\n      <add name=\"WSFederationAuthenticationModule\" type=\"System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" preCondition=\"managedHandler\" \/>\r\n      <add name=\"SessionAuthenticationModule\" type=\"System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" preCondition=\"managedHandler\" \/>\r\n    <\/modules>\r\n  <\/system.webServer>\r\n  <system.identityModel>\r\n    <identityConfiguration>\r\n      <audienceUris>\r\n        <add value=\"https:\/\/localhost:44304\/\" \/>\r\n      <\/audienceUris>\r\n      <securityTokenHandlers>\r\n        <add type=\"System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" \/>\r\n        <remove type=\"System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" \/>\r\n      <\/securityTokenHandlers>\r\n      <certificateValidation certificateValidationMode=\"None\" \/>\r\n      <issuerNameRegistry type=\"System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry\">\r\n        <authority name=\"urn:my:adfs\">\r\n          <keys>\r\n            <add thumbprint=\"F5ADED8729AF0005FA889CCB913C7B7AEFF96B33\" \/>\r\n          <\/keys>\r\n          <validIssuers>\r\n            <add name=\"urn:my:adfs\" \/>\r\n          <\/validIssuers>\r\n        <\/authority>\r\n      <\/issuerNameRegistry>\r\n    <\/identityConfiguration>\r\n  <\/system.identityModel>\r\n  <system.identityModel.services>\r\n    <federationConfiguration>\r\n      <cookieHandler requireSsl=\"true\" \/>\r\n      <wsFederation passiveRedirectEnabled=\"true\" issuer=\"https:\/\/sts.my.com\/adfs\/ls\/\" realm=\"https:\/\/localhost:44304\/\" requireHttps=\"true\" \/>\r\n    <\/federationConfiguration>\r\n  <\/system.identityModel.services>\r\n<\/configuration>\r\n<\/pre>\n<span id=\"Find_Issuer_Name\"><h2>Find Issuer Name<\/h2><\/span>\n<p>* You can find the Issuer Name, e.g. <em>urn:my:adfs<\/em>, from the initial <em>Web.config<\/em> file (see previous section):<\/p>\n<pre lang=\"xml\">\r\n        <authority name=\"urn:my:adfs\">\r\n          ...\r\n          <validIssuers>\r\n            <add name=\"urn:my:adfs\" \/>\r\n          <\/validIssuers>\r\n        <\/authority>\r\n<\/pre>\n<p>* Alternatively, you can find it from ADFS2&#8217;s federationmetadata.xml file:<br \/>\n&#8211; Point browser to federation metadata page, e.g.: <em>https:\/\/sts.my.com\/federationmetadata\/2007-06\/federationmetadata.xml<\/em><br \/>\n&#8211; Find <em>&lt;entityID&gt;<\/em> attribute, which <em>is<\/em> the issuer name, at the beginning of the XML:<\/p>\n<pre lang=\"xml\">\r\n<EntityDescriptor ID=\"xxxx\"\r\n entityID=\"urn:my:adfs\"<\/pre>\n<span id=\"Find_Issuer_Thumbprint\"><h2>Find Issuer Thumbprint<\/h2><\/span>\n<p>* You can find the thumbprint from the initial <em>Web.config<\/em> file (see previous section):<\/p>\n<pre lang=\"xml\">\r\n        <authority name=\"urn:my:adfs\">\r\n          <keys>\r\n            <add thumbprint=\"F5ADED8729AF0005FA889CCB913C7B7AEFF96B33\" \/>\r\n          <\/keys>\r\n<\/pre>\n<p>* Alternatively, you can find thumbprint value from ADFS2's federationmetadata.xml file:<br \/>\n- Point browser to federation metadata page, e.g.: <em>https:\/\/sts.my.com\/federationmetadata\/2007-06\/federationmetadata.xml<\/em><br \/>\n- Find <em>&lt;KeyDescriptor use=\"signing\"&gt;<\/em> element:<\/p>\n<pre lang=\"xml\">\r\n<KeyDescriptor use=\"signing\">\r\n    <KeyInfo xmlns=\"http:\/\/www.w3.org\/2000\/09\/xmldsig#\">\r\n        <X509Data>\r\n            <X509Certificate>xxxxxxxxxxxx<\/X509Certificate>\r\n        <\/X509Data>\r\n    <\/KeyInfo>\r\n<\/KeyDescriptor>\r\n<\/pre>\n<p>- Copy and paste base64 characters between <em>X509Certificate<\/em> element into a temp file with .<em>cer<\/em> file name ending, e.g. <em>mysts_signing.cer<\/em><br \/>\n- Double click the .cer temp file to open the certificate<br \/>\n- Find thumbprint value<\/p>\n<span id=\"_3\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_Thumbprint_1.jpg\" rel=\"attachment wp-att-11561\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_Thumbprint_1.jpg\" alt=\"adfsaspnet1_thumbprint_1\" width=\"412\" height=\"516\" class=\"aligncenter size-full wp-image-11561\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_Thumbprint_1.jpg 412w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/AdfsAspNet1_Thumbprint_1-240x300.jpg 240w\" sizes=\"auto, (max-width: 412px) 100vw, 412px\" \/><\/a><\/h6><\/span>\n<p>* You still need to prepare the thumbprint value:<br \/>\n- Copy thumbprint value (do <strong>NOT <\/strong>copy the first empty space, it contains hidden characters!)<br \/>\n- Remove white spaces<br \/>\n- Upper case whole string, e.g. final value is: <em>F5ADED8729AF0005FA889CCB913C7B7AEFF96B33<\/em><br \/>\n* You'll get \"Error ID4175 and ConfigurationBasedIssuerNameRegistry\" error if you have the wrong thumbprint value.<br \/>\n- See <a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/vstudio\/en-US\/d65aed74-cfde-4bb7-81c7-77b5b566872b\/error-id4175-and-configurationbasedissuernameregistry?forum=Geneva\">this post<\/a> for more details.<\/p>\n<span id=\"Final_Web.config\"><h2>Final Web.config<\/h2><\/span>\n<p>* Initial Web.config generated by Visual Studio is only a starting point.<br \/>\n* Need to modify, e.g.:<br \/>\n- Replace <em>https:\/\/localhost:44306\/<\/em> with actual website URL, <em>e.g. https:\/\/asp.my.com<\/em><br \/>\n* Following is a working example.<\/p>\n<span id=\"Example_Web.config\"><h3>Example Web.config<\/h3><\/span>\n<pre lang=\"xml\">\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<!--\r\n  For more information on how to configure your ASP.NET application, please visit\r\n  http:\/\/go.microsoft.com\/fwlink\/?LinkId=169433\r\n  -->\r\n<configuration>\r\n  <configSections>\r\n    \r\n    <!-- config wif -->\r\n    <section name=\"system.identityModel\" type=\"System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\" \/>\r\n    <section name=\"system.identityModel.services\" type=\"System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\" \/>\r\n  <\/configSections>\r\n\r\n  <appSettings>\r\n    <add key=\"webpages:Version\" value=\"3.0.0.0\" \/>\r\n    <add key=\"webpages:Enabled\" value=\"false\" \/>\r\n    <add key=\"PreserveLoginUrl\" value=\"true\" \/>\r\n    <add key=\"ClientValidationEnabled\" value=\"true\" \/>\r\n    <add key=\"UnobtrusiveJavaScriptEnabled\" value=\"true\" \/>\r\n\r\n    <!-- config wif -->\r\n    <add key=\"ida:FederationMetadataLocation\" value=\"https:\/\/sts.my.com\/federationmetadata\/2007-06\/federationmetadata.xml\" \/>\r\n    <add key=\"ida:Realm\" value=\"https:\/\/myappc.my.com\/myapp\/\" \/>\r\n    <add key=\"ida:AudienceUri\" value=\"https:\/\/myappc.my.com\/myapp\/\" \/>\r\n  <\/appSettings>\r\n  <system.web>\r\n    <customErrors mode=\"Off\"\/>\r\n    <compilation targetFramework=\"4.5\" \/>\r\n    <httpRuntime targetFramework=\"4.5\" requestValidationMode=\"4.5\" \/>\r\n    <pages>\r\n      <namespaces>\r\n        <add namespace=\"System.Web.Helpers\" \/>\r\n        <add namespace=\"System.Web.Mvc\" \/>\r\n        <add namespace=\"System.Web.Mvc.Ajax\" \/>\r\n        <add namespace=\"System.Web.Mvc.Html\" \/>\r\n        <add namespace=\"System.Web.Routing\" \/>\r\n        <add namespace=\"System.Web.WebPages\" \/>\r\n      <\/namespaces>\r\n    <\/pages>\r\n\r\n    <!-- config wif -->\r\n    <authorization>\r\n      <deny users=\"?\" \/>\r\n    <\/authorization>\r\n  <\/system.web>\r\n  <system.webServer>\r\n    <validation validateIntegratedModeConfiguration=\"false\" \/>\r\n    <handlers>\r\n      <remove name=\"ExtensionlessUrlHandler-Integrated-4.0\" \/>\r\n      <remove name=\"OPTIONSVerbHandler\" \/>\r\n      <remove name=\"TRACEVerbHandler\" \/>\r\n      <add name=\"ExtensionlessUrlHandler-Integrated-4.0\" path=\"*.\" verb=\"*\" type=\"System.Web.Handlers.TransferRequestHandler\" preCondition=\"integratedMode,runtimeVersionv4.0\" \/>\r\n    <\/handlers>\r\n    <modules>\r\n\r\n    <!-- config wif -->\r\n      <add name=\"SessionAuthenticationModule\" type=\"System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" preCondition=\"managedHandler\" \/>\r\n      <add name=\"WSFederationAuthenticationModule\" type=\"System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" preCondition=\"managedHandler\" \/>\r\n    <\/modules>\r\n  <\/system.webServer>\r\n\r\n  <!-- config wif -->\r\n  <system.identityModel>\r\n    <identityConfiguration>\r\n      <audienceUris>\r\n        <add value=\"https:\/\/myappc.my.com\/myapp\/\" \/>\r\n      <\/audienceUris>\r\n      <issuerNameRegistry type=\"System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\r\n        <trustedIssuers>\r\n          <!-- name is IdP entityID which can be found in federationmetadata.xml file -->\r\n          <add thumbprint=\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" name=\"urn:my:adfs\" \/>\r\n        <\/trustedIssuers>\r\n      <\/issuerNameRegistry>\r\n      <certificateValidation certificateValidationMode=\"None\" \/>\r\n      <securityTokenHandlers>\r\n        <add type=\"System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" \/>\r\n        <remove type=\"System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" \/>\r\n      <\/securityTokenHandlers>\r\n    <\/identityConfiguration>\r\n  <\/system.identityModel>\r\n\r\n  <!-- config wif -->\r\n  <system.identityModel.services>\r\n    <federationConfiguration>\r\n      <cookieHandler requireSsl=\"true\" \/>\r\n      <wsFederation passiveRedirectEnabled=\"true\" issuer=\"https:\/\/sts.my.com\/adfs\/ls\/\" realm=\"https:\/\/myappc.my.com\/myapp\/\" requireHttps=\"true\" \/>\r\n    <\/federationConfiguration>\r\n  <\/system.identityModel.services>\r\n  <runtime>\r\n    <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Web.Helpers\" publicKeyToken=\"31bf3856ad364e35\" \/>\r\n        <bindingRedirect oldVersion=\"1.0.0.0-3.0.0.0\" newVersion=\"3.0.0.0\" \/>\r\n      <\/dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Web.Mvc\" publicKeyToken=\"31bf3856ad364e35\" \/>\r\n        <bindingRedirect oldVersion=\"0.0.0.0-5.1.0.0\" newVersion=\"5.1.0.0\" \/>\r\n      <\/dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Web.Optimization\" publicKeyToken=\"31bf3856ad364e35\" \/>\r\n        <bindingRedirect oldVersion=\"1.0.0.0-1.1.0.0\" newVersion=\"1.1.0.0\" \/>\r\n      <\/dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"System.Web.WebPages\" publicKeyToken=\"31bf3856ad364e35\" \/>\r\n        <bindingRedirect oldVersion=\"1.0.0.0-3.0.0.0\" newVersion=\"3.0.0.0\" \/>\r\n      <\/dependentAssembly>\r\n      <dependentAssembly>\r\n        <assemblyIdentity name=\"WebGrease\" publicKeyToken=\"31bf3856ad364e35\" \/>\r\n        <bindingRedirect oldVersion=\"1.0.0.0-1.5.2.14234\" newVersion=\"1.5.2.14234\" \/>\r\n      <\/dependentAssembly>\r\n    <\/assemblyBinding>\r\n  <\/runtime>\r\n<\/configuration>\r\n<\/pre>\n<span id=\"Example_Code\"><h2>Example Code<\/h2><\/span>\n<p>* Example to print out all cliam types and values:<\/p>\n<pre lang=\"csharp\">\r\n        protected void Page_Load(object sender, EventArgs e)\r\n        {\r\n            var Identity = (ClaimsIdentity)User.Identity;\r\n            if (!Identity.IsAuthenticated)\r\n            {\r\n                log.ErrorFormat(\"User {0} not authenticated!\", GetUserName(Identity));\r\n            }\r\n            else\r\n            {\r\n                log.InfoFormat(\"User {0} authenticated!\", GetUserName(Identity));\r\n            }\r\n\r\n            var claims = Identity.Claims;\r\n            foreach (Claim c in claims)\r\n            {\r\n                log.InfoFormat(\"Got claim {0} with value {1}\", c.Type, c.Value);\r\n            }\r\n        }\r\n<\/pre>\n<span id=\"Create_Relying_Party\"><h2>Create Relying Party<\/h2><\/span>\n<p>* Login ADFS server<br \/>\n* Open ADFS management console<br \/>\n* Go to: <em>AD FS 2.0 > Trust Relationships > Replying Party Trusts<\/em><br \/>\n* Right click and select <em>Add Relying Party Trust...<\/em><br \/>\n* Click <em>Start <\/em>on Welcome page:<br \/>\n* Select: <em>Enter data about the relying party manually<\/em><br \/>\n* Enter:<br \/>\n- Display name: <strong>Test ADFS2<\/strong><br \/>\n* Select: <em>AD FS 2.0 profile<\/em><br \/>\n* Skip for now on <em>Configure Certificate<\/em> screen<br \/>\n* Select: <em>Enable support for the WS-Federation Passive protocol<\/em><br \/>\n- Relying party WS-Federation Passive protocol URL: <strong>https:\/\/myappc.my.com\/<\/strong><br \/>\n* Click <em>OK <\/em>on <em>Configure Identifiers<\/em><br \/>\n* On <em>Choose Issuance<\/em> screen, select <em>Permit all users to access this replying party<\/em><br \/>\n* Review settings on <em>Ready to Add Trust<\/em> screen<br \/>\n* Click <em>Next <\/em>to add the relying party<\/p>\n<span id=\"Add_Claim_Rules\"><h3>Add Claim Rules<\/h3><\/span>\n<p>* Login ADFS server<br \/>\n* Open ADFS management console<br \/>\n* Go to: <em>AD FS 2.0 > Trust Relationships > Replying Party Trusts<\/em><br \/>\n* Select relying party, e.g. <em>Test ADFS2<\/em><br \/>\n* Click <em>Edit Claim Rules...<\/em><br \/>\n* Click <em>Add Rule...<\/em><br \/>\n* Enter:<br \/>\n- Claim rule name: <strong>Name ID<\/strong><br \/>\n- Attribute store: <em>Active Directory<\/em><br \/>\n- LDAP Attribute: <em>SAM-Account-Name<\/em><br \/>\n- Outgoing Cliam Type: <em>Name ID<\/em><br \/>\n* Click <em>OK <\/em>twice<br \/>\n* Add additional rules, e.g. <em>E-mail Address<\/em><\/p>\n<span id=\"Deploy_ASP.Net_4.5_to_IIS_7.5\"><h2>Deploy ASP.Net 4.5 to IIS 7.5<\/h2><\/span>\n<p>* Start IIS Manager<br \/>\n* Add new application pool<br \/>\n* Add new application<br \/>\n* Enable anonymous authentication<br \/>\n* Enable SSL<br \/>\n* Setup Web.config file<br \/>\n* Restart Default Web Site<\/p>\n<span id=\"Test\"><h2>Test<\/h2><\/span>\n<p>* Point browser to https:\/\/myappc.my.com\/Default.aspx<br \/>\n* Check log file for claims, e.g.<\/p>\n<pre lang=\"bash\">\r\nUser jimmy authenticated!\r\nGot claim http:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/nameidentifier with value jimmy\r\nGot claim http:\/\/schemas.microsoft.com\/ws\/2008\/06\/identity\/claims\/authenticationmethod with value http:\/\/schemas.microsoft.com\/ws\/2008\/06\/identity\/authenticationmethod\/windows\r\nGot claim http:\/\/schemas.microsoft.com\/ws\/2008\/06\/identity\/claims\/authenticationinstant with value 20xx-xx-02T15:40:14.391Z\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Introduction * ASP.Net 4.5 web application can be secured with ADFS 2.0 * Authentication configuration is done in Web.config file Generate Initial Web.config * Use Visual Studio to generate an initial Web.config by pointing to ADFS Federation Metadata URL. * &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=11531\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[346,705],"tags":[632,706],"class_list":["post-11531","post","type-post","status-publish","format-standard","hentry","category-adfs","category-asp-net","tag-adfs","tag-asp-net"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2ZZ","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11531"}],"version-history":[{"count":10,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11531\/revisions"}],"predecessor-version":[{"id":12029,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11531\/revisions\/12029"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}