<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Ben Hickman's Blog</title><link>http://weblogs.asp.net/bhickman/default.aspx</link><description>.NET Ramblings</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Precompiling ASP.NET</title><link>http://weblogs.asp.net/bhickman/archive/2003/02/10/2183.aspx</link><pubDate>Mon, 10 Feb 2003 19:04:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2183</guid><dc:creator>fleenj</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bhickman/rsscomments.aspx?PostID=2183</wfw:commentRss><comments>http://weblogs.asp.net/bhickman/archive/2003/02/10/2183.aspx#comments</comments><description>&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;EM&gt;With this assembly you can easily achieve to precompile your whole ASP.NET web applications - including .aspx, .asmx, .ascx and .ashx files - without having to manually touch every single resource.&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;[&lt;A href="http://dotnetweblogs.com/Cweyer/archive/02072003.aspx#2013"&gt;Christian Weyer: Web Services &amp;amp; .NET&lt;/A&gt;]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This is a nice solution: use&amp;nbsp;the Init method of an HttpModule to precompile everything on app startup.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2183" width="1" height="1"&gt;</description></item><item><title>VSIP</title><link>http://weblogs.asp.net/bhickman/archive/2003/02/10/2180.aspx</link><pubDate>Mon, 10 Feb 2003 18:42:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2180</guid><dc:creator>fleenj</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bhickman/rsscomments.aspx?PostID=2180</wfw:commentRss><comments>http://weblogs.asp.net/bhickman/archive/2003/02/10/2180.aspx#comments</comments><description>&lt;P&gt;&lt;A href="http://dotnetweblogs.com/sgentile/"&gt;Sam&lt;/A&gt; &lt;A href="http://dotnetweblogs.com/sgentile/archive/02082003.aspx#2045"&gt;writes&lt;/A&gt; about &lt;A href="http://msdn.microsoft.com/vstudio/vsip/default.asp"&gt;VSIP&lt;/A&gt;. I just finished a VSIP project for a customer and agree it's a battle. All the typical suspects: doc errors, whole sections undocumented, and light on introductory material.&lt;/P&gt;
&lt;P&gt;I was mostly building Tool Windows and found it most helpful to start with the AIWTool sample project. This allowed me to create ActiveX controls separate from VSIP and them embed them in a Tool Window in VS.NET. &lt;/P&gt;
&lt;P&gt;My main stumbling block right now is integrating with Server Explorer. It's undocumented and I haven't figured it all out yet.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2180" width="1" height="1"&gt;</description></item><item><title>Thanks Scott</title><link>http://weblogs.asp.net/bhickman/archive/2003/02/10/2179.aspx</link><pubDate>Mon, 10 Feb 2003 18:41:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2179</guid><dc:creator>fleenj</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bhickman/rsscomments.aspx?PostID=2179</wfw:commentRss><comments>http://weblogs.asp.net/bhickman/archive/2003/02/10/2179.aspx#comments</comments><description>Thanks &lt;A href="http://radio.weblogs.com/0106747/2003/02/07.html"&gt;Scott&lt;/A&gt;, for the intro. Who knew I had a flourish?&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2179" width="1" height="1"&gt;</description></item><item><title>Custom roles for WindowsPrincipals in ASP.NET</title><link>http://weblogs.asp.net/bhickman/archive/2003/02/07/2018.aspx</link><pubDate>Fri, 07 Feb 2003 21:27:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2018</guid><dc:creator>fleenj</dc:creator><slash:comments>30</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bhickman/rsscomments.aspx?PostID=2018</wfw:commentRss><comments>http://weblogs.asp.net/bhickman/archive/2003/02/07/2018.aspx#comments</comments><description>&lt;P&gt;I continue to be pleased with the many plug-points within ASP.NET. Recently, I had a student with an interesting ASP.NET security challenge. He wanted to use&amp;nbsp;integrated windows authentication, but wanted to&amp;nbsp;assign custom roles for the&amp;nbsp;windows principals. He&amp;nbsp;was building an intranet site.&amp;nbsp;He needed a set of roles that didn't map to any existing Windows groups and he couldn't get the network&amp;nbsp;admins to add them (and keep them updated).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It turns out this is quite easy with ASP.NET. First, create a new class to hold the roles (thankfully, WindowsPrincipal isn't sealed!):&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face="Lucida Console"&gt;using System.Collections;&lt;BR&gt;using System.Security.Principal;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Lucida Console"&gt;public class CustomPrincipal : WindowsPrincipal&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private ArrayList m_Roles;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Lucida Console"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public CustomPrincipal(WindowsIdentity identity): base(identity)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Roles = new ArrayList?();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Lucida Console"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public override bool IsInRole(string role)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // May&amp;nbsp;or may not make sense to check&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // WindowsPrincipal role if membership fails&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // for the local list.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (m_Roles.Contains(role))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return base.IsInRole(role);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Lucida Console"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void AddRole(string role)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Roles.Add(role);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now, add the following code to Global.asax.cs&amp;nbsp;to hook into the Windows authentication process in ASP.NET and setup the new CustomPrincipal and its roles:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face="Lucida Console"&gt;protected void WindowsAuthentication_OnAuthenticate(object sender,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WindowsAuthenticationEventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (e.Identity != null &amp;amp;&amp;amp; e.Identity.IsAuthenticated)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustomPrincipal p = new CustomPrincipal((WindowsIdentity)e.Identity);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Lucida Console"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add the appropriate roles, e.g. read&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // them out of a database.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p.AddRole("CustomRole");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HttpContext.Current.User = p;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then, just use the normal ASP.NET authorization services. You can write code that uses Page.User.IsInRole() or using Web.config, e.g.:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face="Lucida Console"&gt;&amp;lt;authentication mode="Windows" /&amp;gt;&lt;BR&gt;&amp;lt;identity impersonate="true" &amp;gt;&lt;BR&gt;&amp;lt;authorization&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;allow roles="BUILTIN\Administrators" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;allow roles="CustomRole" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;deny users="*" /&amp;gt;&lt;BR&gt;&amp;lt;/authorization&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2018" width="1" height="1"&gt;</description></item><item><title>And Begin</title><link>http://weblogs.asp.net/bhickman/archive/2003/02/07/2009.aspx</link><pubDate>Fri, 07 Feb 2003 20:13:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2009</guid><dc:creator>fleenj</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/bhickman/rsscomments.aspx?PostID=2009</wfw:commentRss><comments>http://weblogs.asp.net/bhickman/archive/2003/02/07/2009.aspx#comments</comments><description>Hello weblog&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2009" width="1" height="1"&gt;</description></item></channel></rss>
