<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by Mahdi Shahbazi</title><link href="http://world.optimizely.com" /><updated>2019-02-01T02:14:00.0000000Z</updated><id>https://world.optimizely.com/blogs/mahdi-shahbazi/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>Active Directory role mapping strategy For Federation Security</title><link href="https://world.optimizely.com/blogs/mahdi-shahbazi/dates/2019/1/active-directory-configuration-for-federation-security/" /><id>&lt;p&gt;When you are dealing&amp;nbsp; with Active directory to handle your authentication you need to make sure that it passes right roles to your application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In case of &lt;strong&gt;Federation Security&lt;/strong&gt;&amp;nbsp;you need to pass the roles as series of &quot;role&quot; claims.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note:&amp;nbsp;System.Security.Claims.ClaimTypes.Role represent &quot;&lt;a href=&quot;http://schemas.microsoft.com/ws/2008/06/identity/claims/role&amp;quot;&quot;&gt;http://schemas.microsoft.com/ws/2008/06/identity/claims/role&quot;&lt;/a&gt;&amp;nbsp;value in dotnet.&lt;/p&gt;
&lt;p&gt;You need to know that there is no concept of role in active directory. Instead we can use groups and map them to &quot;role&quot;.&lt;/p&gt;
&lt;p&gt;There are 2 main Roles in the episerver that you need to Consider them in the mappings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;WebAdmins:&amp;nbsp;&lt;span&gt;can access both admin and edit views and the administration interfaces for add-ons and visitor groups&amp;nbsp;oes&amp;nbsp;not&amp;nbsp;provide editing access in the content structure by default.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;&lt;span&gt;WebEditors:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;Users in This group will get access to &lt;span&gt;edit views&lt;/span&gt;. Users in this group are editors and often organized in other groups according to content structure or languages and won&#39;t have edit access until they get access based on another role or direct access based on username(which is not recomanded).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In Active directory you must define two groups which later will map to WebAdmins and WebEditors. The group&amp;rsquo;s name shouldn&#39;t necessarily&amp;nbsp;be the same since later the Active directory admin will map them to these names when they setup the &lt;strong&gt;Transform Rules&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;These links might be helpful if you have no idea about Transformation in ADFS&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/create-a-rule-to-send-group-membership-as-a-claim&quot;&gt;https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/create-a-rule-to-send-group-membership-as-a-claim&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://support.zendesk.com/hc/en-us/articles/203663896-Mapping-attributes-from-Active-Directory-with-ADFS-and-SAML-Professional-and-Enterprise-&quot;&gt;https://support.zendesk.com/hc/en-us/articles/203663896-Mapping-attributes-from-Active-Directory-with-ADFS-and-SAML-Professional-and-Enterprise-&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you define &amp;ldquo;SiteA&amp;rdquo; group as a member of &amp;ldquo;WebEditors&amp;rdquo; and then define &amp;ldquo;Site A Digital Banking&amp;rdquo; group as a member of &amp;ldquo;WebEditors&amp;rdquo;, any member of &amp;ldquo;Site A Digital Banking&amp;rdquo; will get following roles [WebEditors, SiteA, SiteADigitalBanking].&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you define &amp;ldquo;Marketing&amp;rdquo; group as a member of &amp;ldquo;WebEditors&amp;rdquo;, any member of &amp;ldquo;Marketing&amp;rdquo; will get following roles [WebEditors, Marketing].&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you define &amp;ldquo;Employees&amp;rdquo; group, any member of &amp;ldquo;Employees&amp;rdquo; gets [Employees] role. Obviously if he is not member of &amp;ldquo;&lt;strong&gt;WebEditors&lt;/strong&gt;, &lt;strong&gt;WebAdmins&lt;/strong&gt;&amp;rdquo; he won&amp;rsquo;t be able to go to CMS admin and edit Area and&lt;/p&gt;
&lt;p&gt;If a user is a member of multiple groups, they get all the roles. For instance, a user in employee group and marketing group, will get [WebEditors, Marketing, Employees] roles.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;/link/2d9a645242f845f2975067266438f299.aspx&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Keep in mind that you need to have a &lt;strong&gt;Transformation Rule&lt;/strong&gt; for each group you need to map them to corresponding role. And also, you need to define those roles in EPiServer, beside &lt;strong&gt;WebEditors&lt;/strong&gt;, &lt;strong&gt;WebAdmins&lt;/strong&gt; which are already defined.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Note: Transformation can convert a group to a role. For example you can have epi.cms.webcontenteditor group in Active Directory and map them to &amp;ldquo;WebEditors&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;to define a role in EpiServer you can go to CMS Administrative area=&amp;gt; CMS =&amp;gt; Admin =&amp;gt; Admin =&amp;gt; Administrater Group&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/link/42031f9e441245fbb974dfd0db6fabfd.aspx&quot; width=&quot;1343&quot; height=&quot;535&quot; /&gt;&lt;/p&gt;</id><updated>2019-02-01T02:14:00.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>How to resolve &quot;The request queue limit of the session is exceeded. System.Web.HttpException at System.Web.SessionState.SessionStateModule.QueueRef&quot;</title><link href="https://world.optimizely.com/blogs/mahdi-shahbazi/dates/2018/10/the-request-queue-limit-of-the-session-is-exceeded--system-web-httpexception-at-system-web-sessionstate-sessionstatemodule-queueref/" /><id>&lt;p&gt;If you use DXC, this error might hide behind CDN 524 error page, you should check the error in application insight and if it was the case this is the solution.&lt;/p&gt;
&lt;p&gt;If you are using episerver with .net 4.7 you might get &lt;strong&gt;&quot;The request queue limit of the session is exceeded. System.Web.HttpException at System.Web.SessionState.SessionStateModule.QueueRef&quot;&lt;/strong&gt; in you log or application Insight. the exprieve will be awefull and you need to clear your cache or use incongnito mode to see the page again.&lt;/p&gt;
&lt;p&gt;So what is the cause of the issue?&lt;/p&gt;
&lt;p&gt;In the .NET Framework 4.6.2 and earlier, ASP.NET executes requests with the same Sessionid sequentially, and ASP.NET always issues the Sessionid through cookies by default. If a page takes a long time to respond, it will significantly degrade server performance just by pressing F5 on the browser. In the fix, we added a counter to track the queued requests and terminate the requests when they exceed a specified limit. The default value is 50. If the limit is reached, a warning will be logged in the event log, and an HTTP 500 response may be recorded in the IIS log.(https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/retargeting/4.5.2-4.7)&lt;/p&gt;
&lt;p&gt;so what is the soloution?&amp;nbsp; the only suloution I have in mind is to back to previouse behaviour which can be done by installing &quot;Microsoft.AspNet.SessionState.SessionStateModule&quot; NuGet package and adding following settings in web.config&lt;/p&gt;
&lt;pre class=&quot;language-markup&quot;&gt;&lt;code&gt;&amp;lt;appSettings&amp;gt;
       &amp;lt;add key=&quot;aspnet:RequestQueueLimitPerSession&quot; value=&quot;2147483647&quot;/&amp;gt;
       &amp;lt;add key=&quot;aspnet:AllowConcurrentRequestsPerSession&quot; value=&quot;true&quot; /&amp;gt;
&amp;lt;/appSettings&amp;gt;&lt;/code&gt;&lt;/pre&gt;</id><updated>2018-10-25T02:10:53.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>How to Check Visitor Group Criteria In Code</title><link href="https://world.optimizely.com/blogs/mahdi-shahbazi/dates/2017/1/how-to-check-visitor-group-criteria-in-code/" /><id>&lt;p&gt;If you want to check if a contentAreaItem is match current user all visitor group criteria you can use the following Methods:&lt;/p&gt;
&lt;pre class=&quot;language-csharp&quot;&gt;&lt;code&gt;  public static bool IsMatchCriteria(ContentAreaItem contentAreaItem)
        {
            var result = true;
            contentAreaItem.AllowedRoles.ForEach(role =&amp;gt;
            {
                    result = result &amp;amp;&amp;amp; IsMatchCriteria(role);
            });
            return result;
        }
 

        public static bool IsMatchCriteria(string guid)
        {
            var visitorGroupGuidId = new Guid(guid);
            var visitorGroupRepository = ServiceLocator.Current.GetInstance&amp;lt;IVisitorGroupRepository&amp;gt;();
            var user = HttpContext.Current.User;

            var vgHelper = new VisitorGroupHelper();
            var visitorGroup = visitorGroupRepository.Load(visitorGroupGuidId);
            return vgHelper.IsPrincipalInGroup(user, visitorGroup.Name);
        }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;[Pasting files is not allowed]&lt;/span&gt;&lt;span&gt;[Pasting files is not allowed]&lt;/span&gt;&lt;span&gt;[Pasting files is not allowed]&lt;/span&gt;&lt;span&gt;[Pasting files is not allowed]&lt;/span&gt;&lt;/p&gt;</id><updated>2017-01-04T11:22:29.4770000Z</updated><summary type="html">Blog post</summary></entry></feed>