{"id":523,"date":"2008-02-10T17:42:03","date_gmt":"2008-02-10T22:42:03","guid":{"rendered":"http:\/\/blogs.devhorizon.com\/reza\/?p=523"},"modified":"2008-02-10T18:27:00","modified_gmt":"2008-02-10T23:27:00","slug":"anonymous-users-in-sharepoint-part-3-welcome-guest","status":"publish","type":"post","link":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/","title":{"rendered":"Anonymous Users In SharePoint (Part 3) : Welcome Guest"},"content":{"rendered":"<p>In previous posts, I mentioned that I would show you how to extend Solution 1 and 2 by somehow merging them into an existing authentication provider and finally packaging everything into a feature called &#8220;Guest Account Enabler&#8221;. An obvious benefit to creating a feature is that it makes it optional to have the guest account functionality in your site. In this post and for the sake of brevity, I assume that Internet Zone (Protected by FBA) is the zone that you want to have the Guest Account enabled , but nothing prevents you from changing the code below to extend it to other zones using the same authentication provider as Internet zone.<\/p>\n<p>If you haven&#8217;t already read Part1 and Part 2 , here are the links:<\/p>\n<ul>\n<li><a href=\"https:\/\/blogs.devhorizon.com\/reza\/?p=498\">Anonymous Users In SharePoint (Part 1) : Introduction<\/a><\/li>\n<li><a href=\"https:\/\/blogs.devhorizon.com\/reza\/?p=508\">Anonymous Users In SharePoint (Part 2): Solutions<\/a><\/li>\n<\/ul>\n<p>The first step is to create our &#8216;Global.asax&#8217; file. While our &#8216;Global.asax&#8217; is very similar to the ones shown in Solution 1 and 2 in part 2, it has one important difference. It constructs the &#8216;Guest&#8217; account only if the relevant feature is activated. Here is the code for new &#8216;Global.asax&#8217;.<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">C#<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"csharp\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&lt;%<\/span>@ Assembly Name<span style=\"color: #008000\">=<\/span><span style=\"color: #666666\">&quot;Microsoft.SharePoint&quot;<\/span><span style=\"color: #008000\">%&gt;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&lt;%<\/span>@ Application Language<span style=\"color: #008000\">=<\/span><span style=\"color: #666666\">&quot;C#&quot;<\/span> Inherits<span style=\"color: #008000\">=<\/span><span style=\"color: #666666\">&quot;Microsoft.SharePoint.ApplicationRuntime.SPHttpApplication&quot;<\/span> <span style=\"color: #008000\">%&gt;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&lt;<\/span>script &nbsp;RunAt<span style=\"color: #008000\">=<\/span><span style=\"color: #666666\">'server'<\/span><span style=\"color: #008000\">&gt;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #6666cc;font-weight: bold\">void<\/span> FormsAuthentication_OnAuthenticate<span style=\"color: #008000\">&#040;<\/span><span style=\"color: #6666cc;font-weight: bold\">object<\/span> sender, FormsAuthenticationEventArgs args<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008080;font-style: italic\">\/\/Extract the forms authentication cookie<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #6666cc;font-weight: bold\">string<\/span> cookieName <span style=\"color: #008000\">=<\/span> FormsAuthentication<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">FormsCookieName<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; HttpCookie authCookie <span style=\"color: #008000\">=<\/span> Context<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Request<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Cookies<\/span><span style=\"color: #008000\">&#091;<\/span>cookieName<span style=\"color: #008000\">&#093;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">if<\/span> <span style=\"color: #008000\">&#040;<\/span><span style=\"color: #0600FF;font-weight: bold\">null<\/span> <span style=\"color: #008000\">==<\/span> authCookie<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008080;font-style: italic\">\/\/ There is no authentication cookie. Check to see if Guest Account feature is activated <\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008080;font-style: italic\">\/\/ If Feature is Activated, ValidateUser would return Guest Account Context <\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">if<\/span> <span style=\"color: #008000\">&#040;<\/span>Membership<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">ValidateUser<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #666666\">&quot;Guest&quot;<\/span>, <span style=\"color: #666666\">&quot;&quot;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FormsAuthentication<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">SetAuthCookie<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #666666\">&quot;Guest&quot;<\/span>, <span style=\"color: #0600FF;font-weight: bold\">true<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span> &nbsp; &nbsp; &nbsp; &nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&lt;\/<\/span>script<span style=\"color: #008000\">&gt;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Only one thing needs to be highlighted here: Membership.ValidateUser(&#8220;Guest&#8221;, &#8220;&#8221;). I added this condition to &#8216;Global.asax&#8217; to check to see if the feature is activated or not. As you will see later in this post , ValidateUser() method of our custom authentication provider will return False if the corresponding feature is not activate. As such  &#8220;Guest Account&#8221;  security context (FBA token) won&#8217;t be constructed for anonymous users in FormsAuthentication_OnAuthenticate and annonymous users will continue to their journey in your site as an unnamed identity as before.<\/p>\n<p>With the &#8216;Global.asax&#8217; properly coded , the next step is create the a Feature. All Features must contain a Feature definition file, so go ahead and add a new XML file to your project named Feature.xml and add the following code to the file.<\/p>\n<div id=\"ig-sh-2\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">xml<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"xml\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"><span style=\"color: #000000;font-weight: bold\">&lt;?xml<\/span> <span style=\"color: #000066\">version<\/span>=<span style=\"color: #ff0000\">&quot;1.0&quot;<\/span> <span style=\"color: #000066\">encoding<\/span>=<span style=\"color: #ff0000\">&quot;utf-8&quot;<\/span> <span style=\"color: #000000;font-weight: bold\">?&gt;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"><span style=\"color: #000000;font-weight: bold\">&lt;Feature<\/span> <span style=\"color: #000066\">xmlns<\/span>=<span style=\"color: #ff0000\">&quot;http:\/\/schemas.microsoft.com\/sharepoint\/&quot;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"> &nbsp; &nbsp;<span style=\"color: #000066\">Description<\/span>=<span style=\"color: #ff0000\">&quot;Enables a guest account that can be targetted for annonymous users&quot;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"> &nbsp; &nbsp;<span style=\"color: #000066\">Id<\/span>=<span style=\"color: #ff0000\">&quot;602D09E4-4F0D-4058-951D-55059BA87943&quot;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"> &nbsp; &nbsp;<span style=\"color: #000066\">Scope<\/span>=<span style=\"color: #ff0000\">&quot;Site&quot;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"> &nbsp; &nbsp;<span style=\"color: #000066\">Hidden<\/span>=<span style=\"color: #ff0000\">&quot;False&quot;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"> &nbsp; &nbsp;<span style=\"color: #000066\">Title<\/span>=<span style=\"color: #ff0000\">&quot;Guest account enabler for annonymous users&quot;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"> &nbsp; &nbsp;<span style=\"color: #000066\">Version<\/span>=<span style=\"color: #ff0000\">&quot;1.0.0.0&quot;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"> &nbsp; &nbsp;<span style=\"color: #000066\">ReceiverAssembly<\/span>=<span style=\"color: #ff0000\">&quot;CustomAuthProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=88ce7fc8bcece008&quot;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"> &nbsp; &nbsp;<span style=\"color: #000066\">ReceiverClass<\/span>=<span style=\"color: #ff0000\">&quot;CustomAuthProvider.GuestFeatureReceiver&quot;<\/span><span style=\"color: #000000;font-weight: bold\">&gt;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #009900\"><span style=\"color: #000000;font-weight: bold\">&lt;ElementManifests<span style=\"color: #000000;font-weight: bold\">&gt;<\/span><\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; <span style=\"color: #009900\"><span style=\"color: #000000;font-weight: bold\">&lt;ElementFile<\/span> <span style=\"color: #000066\">Location<\/span>=<span style=\"color: #ff0000\">&quot;global.asax&quot;<\/span> <span style=\"color: #000000;font-weight: bold\">\/&gt;<\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #009900\"><span style=\"color: #000000;font-weight: bold\">&lt;\/ElementManifests<span style=\"color: #000000;font-weight: bold\">&gt;<\/span><\/span><\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\"><span style=\"color: #000000;font-weight: bold\">&lt;\/Feature<span style=\"color: #000000;font-weight: bold\">&gt;<\/span><\/span><\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Well,  our feature declares a FeatureReciever  that needs to be coded to take care of some deployment tasks for us. This includes copying our custom &#8216;Global.asax&#8217; file  (declared as ElementFile in ElementManifests node) to the root directory of site that servers incoming traffic from internet (Internet Zone). Here is the FeatureActivated method:<\/p>\n<div id=\"ig-sh-3\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">C#<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"csharp\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #0600FF;font-weight: bold\">override<\/span> <span style=\"color: #6666cc;font-weight: bold\">void<\/span> FeatureActivated<span style=\"color: #008000\">&#040;<\/span>SPFeatureReceiverProperties properties<span style=\"color: #008000\">&#041;<\/span> <\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SPSite site <span style=\"color: #008000\">=<\/span> properties<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Feature<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Parent<\/span> <span style=\"color: #0600FF;font-weight: bold\">as<\/span> SPSite<span style=\"color: #008000\">;<\/span> &nbsp; &nbsp;<span style=\"color: #008080;font-style: italic\">\/\/ get site reference<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SPWebApplication webApp <span style=\"color: #008000\">=<\/span> site<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">WebApplication<\/span> <span style=\"color: #0600FF;font-weight: bold\">as<\/span> SPWebApplication<span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">foreach<\/span> <span style=\"color: #008000\">&#040;<\/span>SPUrlZone zone <span style=\"color: #0600FF;font-weight: bold\">in<\/span> webApp<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">IisSettings<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Keys<\/span><span style=\"color: #008000\">&#041;<\/span> <\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">if<\/span> <span style=\"color: #008000\">&#040;<\/span>zone <span style=\"color: #008000\">==<\/span> SPUrlZone<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Internet<\/span><span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008080;font-style: italic\">\/\/ The settings of the IIS application to copy global.asax file to. &nbsp; &nbsp; <\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SPIisSettings oSettings <span style=\"color: #008000\">=<\/span> webApp<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">IisSettings<\/span><span style=\"color: #008000\">&#091;<\/span>zone<span style=\"color: #008000\">&#093;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008080;font-style: italic\">\/\/ Determine the source and destination path &nbsp; &nbsp; <\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #6666cc;font-weight: bold\">string<\/span> sourcePath <span style=\"color: #008000\">=<\/span> <span style=\"color: #6666cc;font-weight: bold\">string<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Format<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #666666\">@&quot;{0}\\FEATURES\\{1}\\&quot;<\/span>, SPUtility<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">GetGenericSetupPath<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #666666\">&quot;Template&quot;<\/span><span style=\"color: #008000\">&#041;<\/span>,<span style=\"color: #666666\">@&quot;\\GuestEnablerFeature&quot;<\/span> <span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #6666cc;font-weight: bold\">string<\/span> destPath <span style=\"color: #008000\">=<\/span> oSettings<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Path<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">ToString<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; File<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Copy<\/span><span style=\"color: #008000\">&#040;<\/span>Path<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Combine<\/span><span style=\"color: #008000\">&#040;<\/span>sourcePath, <span style=\"color: #666666\">&quot;global.asax&quot;<\/span><span style=\"color: #008000\">&#041;<\/span>, Path<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Combine<\/span><span style=\"color: #008000\">&#040;<\/span>destPath, <span style=\"color: #666666\">&quot;global.asax&quot;<\/span><span style=\"color: #008000\">&#041;<\/span>, <span style=\"color: #0600FF;font-weight: bold\">true<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>With the shell of our Feature created , the next step is going to the actual Authentication Provider code and change following overridden methods to support &#8220;Guest Account&#8221; capability for anonymous users.<\/p>\n<ul>\n<li>ValidateUser<\/li>\n<li>GetUser<\/li>\n<li>GetAllUsers<\/li>\n<li>FindUsersByName<\/li>\n<\/ul>\n<div id=\"ig-sh-4\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">C#<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"csharp\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #0600FF;font-weight: bold\">override<\/span> <span style=\"color: #6666cc;font-weight: bold\">bool<\/span> ValidateUser<span style=\"color: #008000\">&#040;<\/span><span style=\"color: #6666cc;font-weight: bold\">string<\/span> username, <span style=\"color: #6666cc;font-weight: bold\">string<\/span> password<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #008080;font-style: italic\">\/\/Check to see if Guest Enabler Feature is installed and activated<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #6666cc;font-weight: bold\">bool<\/span> showGuestAccount <span style=\"color: #008000\">=<\/span> Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">IsSiteFeatureActivated<\/span><span style=\"color: #008000\">&#040;<\/span>HttpContext<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Current<\/span>, <span style=\"color: #666666\">&quot;602D09E4-4F0D-4058-951D-55059BA87943&quot;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #0600FF;font-weight: bold\">if<\/span> <span style=\"color: #008000\">&#040;<\/span>username <span style=\"color: #008000\">==<\/span> <span style=\"color: #666666\">&quot;Guest&quot;<\/span> <span style=\"color: #008000\">&amp;<\/span>amp<span style=\"color: #008000\">;&amp;<\/span>amp<span style=\"color: #008000\">;<\/span> showGuestAccount<span style=\"color: #008000\">&#041;<\/span> <span style=\"color: #0600FF;font-weight: bold\">return<\/span> <span style=\"color: #0600FF;font-weight: bold\">true<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<span style=\"color: #008080;font-style: italic\">\/\/the rest of your code to validate non-guest users goes here<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<div id=\"ig-sh-5\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">C#<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"csharp\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #0600FF;font-weight: bold\">override<\/span> MembershipUser GetUser<span style=\"color: #008000\">&#040;<\/span><span style=\"color: #6666cc;font-weight: bold\">string<\/span> username, <span style=\"color: #6666cc;font-weight: bold\">bool<\/span> userIsOnline<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #008080;font-style: italic\">\/\/Check to see if Guest Enabler Feature is installed and activated<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #6666cc;font-weight: bold\">bool<\/span> showGuestAccount <span style=\"color: #008000\">=<\/span> Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">IsSiteFeatureActivated<\/span><span style=\"color: #008000\">&#040;<\/span>HttpContext<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Current<\/span>, <span style=\"color: #666666\">&quot;602D09E4-4F0D-4058-951D-55059BA87943&quot;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #0600FF;font-weight: bold\">return<\/span> Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">GetUserByFilter<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #0600FF;font-weight: bold\">this<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Name<\/span>,<span style=\"color: #0600FF;font-weight: bold\">this<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">ConnectionString<\/span>,Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">UsersFilter<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">UserName<\/span>,username,showGuestAccount<span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<div id=\"ig-sh-6\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">C#<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"csharp\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #0600FF;font-weight: bold\">override<\/span> MembershipUserCollection GetAllUsers<span style=\"color: #008000\">&#040;<\/span><span style=\"color: #6666cc;font-weight: bold\">int<\/span> pageIndex, <span style=\"color: #6666cc;font-weight: bold\">int<\/span> pageSize, <span style=\"color: #0600FF;font-weight: bold\">out<\/span> <span style=\"color: #6666cc;font-weight: bold\">int<\/span> totalRecords<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #008080;font-style: italic\">\/\/Check to see if Guest Enabler Feature is installed and activated<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #6666cc;font-weight: bold\">bool<\/span> showGuestAccount <span style=\"color: #008000\">=<\/span> Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">IsSiteFeatureActivated<\/span><span style=\"color: #008000\">&#040;<\/span>HttpContext<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Current<\/span>, <span style=\"color: #666666\">&quot;602D09E4-4F0D-4058-951D-55059BA87943&quot;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #0600FF;font-weight: bold\">return<\/span> Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">GetUsersByFilter<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #0600FF;font-weight: bold\">this<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Name<\/span>,<span style=\"color: #0600FF;font-weight: bold\">this<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">ConnectionString<\/span>,Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">UsersFilter<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Empty<\/span>,<span style=\"color: #0600FF;font-weight: bold\">null<\/span>,pageIndex,pageSize,<span style=\"color: #0600FF;font-weight: bold\">out<\/span> totalRecords,showGuestAccount<span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<div id=\"ig-sh-7\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">C#<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"csharp\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #0600FF;font-weight: bold\">override<\/span> MembershipUserCollection FindUsersByName<span style=\"color: #008000\">&#040;<\/span><span style=\"color: #6666cc;font-weight: bold\">string<\/span> usernameToMatch, <span style=\"color: #6666cc;font-weight: bold\">int<\/span> pageIndex, <span style=\"color: #6666cc;font-weight: bold\">int<\/span> pageSize, <span style=\"color: #0600FF;font-weight: bold\">out<\/span> <span style=\"color: #6666cc;font-weight: bold\">int<\/span> totalRecords<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #008080;font-style: italic\">\/\/Check to see if Guest Enabler Feature is installed and activated<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #6666cc;font-weight: bold\">bool<\/span> showGuestAccount <span style=\"color: #008000\">=<\/span> Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">IsSiteFeatureActivated<\/span><span style=\"color: #008000\">&#040;<\/span>HttpContext<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Current<\/span>, <span style=\"color: #666666\">&quot;602D09E4-4F0D-4058-951D-55059BA87943&quot;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; <span style=\"color: #0600FF;font-weight: bold\">return<\/span> Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">GetUsersByFilter<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #0600FF;font-weight: bold\">this<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Name<\/span>,<span style=\"color: #0600FF;font-weight: bold\">this<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">ConnectionString<\/span>,Utils<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">UsersFilter<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">UserName<\/span>,usernameToMatch,pageIndex,pageSize,<span style=\"color: #0600FF;font-weight: bold\">out<\/span> totalRecords, &nbsp;showGuestAccount<span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Three things need some explanation in the preceding code snippets.<\/p>\n<ol>\n<li>I have used couple helper methods in the above code snippets which is included below.<\/li>\n<li>You need to virtually construct the &#8216;Guest Account&#8217; as a MembershipUser object in GetUser()  when this method is called.<\/li>\n<li>You need to add the &#8216;Guest Account&#8217; to the MembershipUserCollection in GestAllUsers() and FindUsersByName() so &#8220;People Picker&#8221; can resolve that account for targeting content or assigning permission purposes.<\/li>\n<\/ol>\n<div id=\"ig-sh-8\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">C#<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"csharp\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #6666cc;font-weight: bold\">class<\/span> Utils<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #6666cc;font-weight: bold\">enum<\/span> UsersFilter <span style=\"color: #008000\">&#123;<\/span> Email, UserName, Empty <span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #0600FF;font-weight: bold\">static<\/span> <span style=\"color: #6666cc;font-weight: bold\">bool<\/span> IsSiteFeatureActivated<span style=\"color: #008000\">&#040;<\/span>HttpContext context,<span style=\"color: #6666cc;font-weight: bold\">string<\/span> featureID<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SPWebApplication app <span style=\"color: #008000\">=<\/span> SPWebApplication<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Lookup<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #008000\">new<\/span> Uri<span style=\"color: #008000\">&#040;<\/span>context<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Request<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Url<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">AbsoluteUri<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">using<\/span><span style=\"color: #008000\">&#040;<\/span>SPSite site <span style=\"color: #008000\">=<\/span> app<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Sites<\/span><span style=\"color: #008000\">&#091;<\/span><span style=\"color: #FF0000\">0<\/span><span style=\"color: #008000\">&#093;<\/span><span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SPFeature returnsiteFeatures <span style=\"color: #008000\">=<\/span> site<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Features<\/span><span style=\"color: #008000\">&#091;<\/span><span style=\"color: #008000\">new<\/span> Guid<span style=\"color: #008000\">&#040;<\/span>featureID<span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">&#093;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">return<\/span> <span style=\"color: #008000\">&#040;<\/span>returnsiteFeatures <span style=\"color: #008000\">!=<\/span> <span style=\"color: #0600FF;font-weight: bold\">null<\/span> <span style=\"color: #008000\">?<\/span> <span style=\"color: #0600FF;font-weight: bold\">true<\/span> <span style=\"color: #008000\">:<\/span> <span style=\"color: #0600FF;font-weight: bold\">false<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008080;font-style: italic\">\/\/Create a MembershipUserCollection consisting of our single user.<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #0600FF;font-weight: bold\">static<\/span> MembershipUserCollection AddAnnonUserToMembershipCollection<span style=\"color: #008000\">&#040;<\/span><span style=\"color: #6666cc;font-weight: bold\">string<\/span> procviderName, MembershipUserCollection users<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; users<span style=\"color: #008000\">.<\/span><span style=\"color: #0600FF;font-weight: bold\">Add<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #008000\">new<\/span> MembershipUser<span style=\"color: #008000\">&#040;<\/span>procviderName, <span style=\"color: #666666\">&quot;Guest&quot;<\/span>,<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #666666\">&quot;Guest&quot;<\/span>, <span style=\"color: #6666cc;font-weight: bold\">string<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Empty<\/span>, <span style=\"color: #6666cc;font-weight: bold\">string<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Empty<\/span>, <span style=\"color: #6666cc;font-weight: bold\">string<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Empty<\/span>, <span style=\"color: #0600FF;font-weight: bold\">true<\/span>, <span style=\"color: #0600FF;font-weight: bold\">false<\/span>,<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span>, DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span>, DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span>,<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span>, DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">return<\/span> users<span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span> <\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #0600FF;font-weight: bold\">static<\/span> MembershipUserCollection GetUsersByFilter<span style=\"color: #008000\">&#040;<\/span><span style=\"color: #6666cc;font-weight: bold\">string<\/span> procviderName, <span style=\"color: #6666cc;font-weight: bold\">string<\/span> connectionString, UsersFilter filter, <span style=\"color: #6666cc;font-weight: bold\">string<\/span> <span style=\"color: #0600FF;font-weight: bold\">value<\/span>, <span style=\"color: #6666cc;font-weight: bold\">int<\/span> pageIndex, <span style=\"color: #6666cc;font-weight: bold\">int<\/span> pageSize, <span style=\"color: #0600FF;font-weight: bold\">out<\/span> <span style=\"color: #6666cc;font-weight: bold\">int<\/span> totalRecords, <span style=\"color: #6666cc;font-weight: bold\">bool<\/span> includeGuestUser<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MembershipUserCollection resultUsers<span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008080;font-style: italic\">\/\/ Code to get All users based on the filer specified and populate resultUsers collection goes here (removed for code brevity)<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008080;font-style: italic\">\/\/Check to see if you need to add Guest account to the collection<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">if<\/span> <span style=\"color: #008000\">&#040;<\/span>includeGuestUser<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totalRecords <span style=\"color: #008000\">+=<\/span> <span style=\"color: #FF0000\">1<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">return<\/span> AddAnnonUserToMembershipCollection<span style=\"color: #008000\">&#040;<\/span>procviderName, resultUsers<span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">else<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">return<\/span> resultUsers<span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">public<\/span> <span style=\"color: #0600FF;font-weight: bold\">static<\/span> MembershipUser GetUserByFilter<span style=\"color: #008000\">&#040;<\/span><span style=\"color: #6666cc;font-weight: bold\">string<\/span> providerName, <span style=\"color: #6666cc;font-weight: bold\">string<\/span> connectionString, UsersFilter filter, <span style=\"color: #6666cc;font-weight: bold\">string<\/span> <span style=\"color: #0600FF;font-weight: bold\">value<\/span>, <span style=\"color: #6666cc;font-weight: bold\">bool<\/span> includeGuestUser<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#123;<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">if<\/span> <span style=\"color: #008000\">&#040;<\/span><span style=\"color: #0600FF;font-weight: bold\">value<\/span> <span style=\"color: #008000\">==<\/span> <span style=\"color: #666666\">&quot;Guest&quot;<\/span> <span style=\"color: #008000\">&amp;&amp;<\/span> includeGuestUser<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #0600FF;font-weight: bold\">return<\/span> <span style=\"color: #008000\">new<\/span> MembershipUser<span style=\"color: #008000\">&#040;<\/span>providerName, <span style=\"color: #666666\">&quot;Guest&quot;<\/span>, <span style=\"color: #666666\">&quot;Guest&quot;<\/span>, <span style=\"color: #6666cc;font-weight: bold\">string<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Empty<\/span>, <span style=\"color: #6666cc;font-weight: bold\">string<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Empty<\/span>, <span style=\"color: #6666cc;font-weight: bold\">string<\/span><span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Empty<\/span>, <span style=\"color: #0600FF;font-weight: bold\">true<\/span>, <span style=\"color: #0600FF;font-weight: bold\">false<\/span>, DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span>, DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span>, DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span>, DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span>, DateTime<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">MinValue<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008080;font-style: italic\">\/\/rest of your code to get non-guest user goes here<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; <span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Once you have created all of the required pieces and deployed your feature in a solution package (not explained in this post), then you will see that our Feature in the Features collection as shown below:<\/p>\n<table style=\"border-collapse: collapse\" border=\"0\">\n<tr>\n<td style=\"border: 0.5pt solid black; padding-left: 7px; padding-right: 7px\"><img decoding=\"async\" src=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/02\/021008-2242-anonymousus1.png\" \/><\/td>\n<\/tr>\n<\/table>\n<p>\nGo ahead and activate the feature. You will notice that the &#8216;Global.asax&#8217; of your internet zone is replaced with your own custom one and subsequently any anonymous calls will be executed under the security context of  our virtual &#8216;Guest Account&#8217;. If you disable the feature  everything goes back to normal life.<\/p>\n<table style=\"border-collapse: collapse\" border=\"0\">\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\">Feature is activated<\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\"><img decoding=\"async\" src=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/02\/021008-2242-anonymousus2.png\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\">&nbsp;<\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\">Guest Account is resolved in all zones<\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\"><img decoding=\"async\" src=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/02\/021008-2242-anonymousus3.png\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\">&nbsp;<\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\">People Picker shows Guest Account<\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\"><img decoding=\"async\" src=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/02\/021008-2242-anonymousus4.png\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\">&nbsp;<\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\">Feature is deactivated<\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\"><img decoding=\"async\" src=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/02\/021008-2242-anonymousus5.png\" \/><\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px\">&nbsp;<\/td>\n<\/tr>\n<\/table>\n<p>This pretty much concludes my three-part series on Anonymous Users in SharePoint. Hope you have found them useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In previous posts, I mentioned that I would show you how to extend Solution 1 and 2 by somehow merging them into an existing authentication provider and finally packaging everything into a feature called &#8220;Guest Account Enabler&#8221;. An obvious benefit to creating a feature is that it makes it optional to have the guest account [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-523","post","type-post","status-publish","format-standard","hentry","category-moss-2007"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Anonymous Users In SharePoint (Part 3) : Welcome Guest - Reza Alirezaei&#039;s Blog %<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Reza Alirezaei\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/\"},\"author\":{\"name\":\"Reza Alirezaei\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\"},\"headline\":\"Anonymous Users In SharePoint (Part 3) : Welcome Guest\",\"datePublished\":\"2008-02-10T22:42:03+00:00\",\"dateModified\":\"2008-02-10T23:27:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/\"},\"wordCount\":1121,\"commentCount\":21,\"image\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2008\\\/02\\\/021008-2242-anonymousus1.png\",\"articleSection\":[\"MOSS 2007\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/\",\"name\":\"Anonymous Users In SharePoint (Part 3) : Welcome Guest - Reza Alirezaei's Blog %\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2008\\\/02\\\/021008-2242-anonymousus1.png\",\"datePublished\":\"2008-02-10T22:42:03+00:00\",\"dateModified\":\"2008-02-10T23:27:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/02\\\/10\\\/anonymous-users-in-sharepoint-part-3-welcome-guest\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2008\\\/02\\\/021008-2242-anonymousus1.png\",\"contentUrl\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2008\\\/02\\\/021008-2242-anonymousus1.png\",\"width\":783,\"height\":50},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#website\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/\",\"name\":\"Reza Alirezaei's Blog\",\"description\":\"Blogging from the field!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\",\"name\":\"Reza Alirezaei\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"caption\":\"Reza Alirezaei\"},\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/author\\\/rezaa\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Anonymous Users In SharePoint (Part 3) : Welcome Guest - Reza Alirezaei's Blog %","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/","twitter_misc":{"Written by":"Reza Alirezaei","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/#article","isPartOf":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/"},"author":{"name":"Reza Alirezaei","@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938"},"headline":"Anonymous Users In SharePoint (Part 3) : Welcome Guest","datePublished":"2008-02-10T22:42:03+00:00","dateModified":"2008-02-10T23:27:00+00:00","mainEntityOfPage":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/"},"wordCount":1121,"commentCount":21,"image":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/#primaryimage"},"thumbnailUrl":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/02\/021008-2242-anonymousus1.png","articleSection":["MOSS 2007"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/","url":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/","name":"Anonymous Users In SharePoint (Part 3) : Welcome Guest - Reza Alirezaei's Blog %","isPartOf":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/#primaryimage"},"image":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/#primaryimage"},"thumbnailUrl":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/02\/021008-2242-anonymousus1.png","datePublished":"2008-02-10T22:42:03+00:00","dateModified":"2008-02-10T23:27:00+00:00","author":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/02\/10\/anonymous-users-in-sharepoint-part-3-welcome-guest\/#primaryimage","url":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/02\/021008-2242-anonymousus1.png","contentUrl":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/02\/021008-2242-anonymousus1.png","width":783,"height":50},{"@type":"WebSite","@id":"https:\/\/blogs.devhorizon.com\/reza\/#website","url":"https:\/\/blogs.devhorizon.com\/reza\/","name":"Reza Alirezaei's Blog","description":"Blogging from the field!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blogs.devhorizon.com\/reza\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938","name":"Reza Alirezaei","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","caption":"Reza Alirezaei"},"url":"https:\/\/blogs.devhorizon.com\/reza\/author\/rezaa\/"}]}},"_links":{"self":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/comments?post=523"}],"version-history":[{"count":0,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/523\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/media?parent=523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/categories?post=523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/tags?post=523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}