<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>crunchlife: Expect the Unexpected: bool IsInRole(string role)</title>
    <link>http://crunchlife.com/articles/2007/07/09/expect-the-unexpected-bool-isinrole-string-role</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Expect the Unexpected: bool IsInRole(string role)</title>
      <description>&lt;p&gt;Running some tests yesterday, I was alarmed by an Exception that read, &amp;#8220;The trust relationship between the primary domain and the trusted domain failed.&amp;#8221;  What?!?  This code worked a few weeks ago!  The method in question called Page.User.IsInRole(&amp;#8220;DomainName\RoleName&amp;#8221;) to determine if a user was assigned to an administrator&amp;#8217;s role.  bool IsAdministrator().  Simple and efficient.  Why is this happening?!?&lt;/p&gt;

&lt;p&gt;&lt;img src="/files/IsInRole_Error.png" alt="IsInRole"/&gt;&lt;/p&gt;

&lt;p&gt;In short, the role that I was supplying Page.User.IsInRole with contained a typo.  What is interesting is the results of my test case found below.  Pay attention to the method signatures and their outcome.&lt;/p&gt;

&lt;p&gt;Page.User.IsInRole(&amp;#8220;DomainName\RoleName&amp;#8221;) returns true&lt;br /&gt;
Page.User.IsInRole(&amp;#8220;RoleName&amp;#8221;) returns true&lt;/p&gt;

&lt;p&gt;Page.User.IsInRole(&amp;#8220;DomainName\TypoRoleName&amp;#8221;) returns false&lt;/p&gt;

&lt;p&gt;But&amp;#8230;&lt;/p&gt;

&lt;p&gt;Page.User.IsInRole(&amp;#8220;TypoRoleName&amp;#8221;) throws the Exception&lt;/p&gt;

&lt;p&gt;Huh?&lt;/p&gt;

&lt;p&gt;I haven&amp;#8217;t had time to dig further into this, but I&amp;#8217;d definitely be interested in hearing some opinions.&lt;/p&gt;</description>
      <pubDate>Mon, 09 Jul 2007 19:34:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:5abe8be8-b46a-46c6-846d-ee10ec979f46</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2007/07/09/expect-the-unexpected-bool-isinrole-string-role</link>
      <category>Expect the Unexpected</category>
      <category>ASPNET</category>
    </item>
    <item>
      <title>"Expect the Unexpected: bool IsInRole(string role)" by paris sportif</title>
      <description>thanks</description>
      <pubDate>Sat, 05 Mar 2011 09:57:34 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:667dabf7-8ec6-4e52-85f0-714e66f58b57</guid>
      <link>http://crunchlife.com/articles/2007/07/09/expect-the-unexpected-bool-isinrole-string-role#comment-147201</link>
    </item>
    <item>
      <title>"Expect the Unexpected: bool IsInRole(string role)" by Ryan</title>
      <description>Well done - this saved me hours - I was about to reconfig all the AD perms...

Thanks!!</description>
      <pubDate>Mon, 21 Sep 2009 00:31:36 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:c0d5d873-f7e3-42cf-ba1f-36f96293084a</guid>
      <link>http://crunchlife.com/articles/2007/07/09/expect-the-unexpected-bool-isinrole-string-role#comment-29241</link>
    </item>
    <item>
      <title>"Expect the Unexpected: bool IsInRole(string role)" by Ryan Baxter</title>
      <description>a silent rogue - Your explanation does make sense given the results of my test case. I suppose sometimes True or False just isn't enough. :)</description>
      <pubDate>Wed, 11 Jul 2007 12:25:30 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:e1402e56-f0dd-4204-8d25-77d73fa62f3e</guid>
      <link>http://crunchlife.com/articles/2007/07/09/expect-the-unexpected-bool-isinrole-string-role#comment-4</link>
    </item>
    <item>
      <title>"Expect the Unexpected: bool IsInRole(string role)" by a silent rogue</title>
      <description>My first guess would be that when you type in just a single identifier, in this case, a typo'd rolename, it cannot distinguish whether you are specifying a rolename or a domainname.  By default, it checks rolenames in the default domain.  When it doesn't find any, I think it is assuming you meant a domain, so it tries and fails to connect to a domain with name of typorolename.  Perhaps if it cannot connect to the domain, it assumes it is because it does not have a trust relationship, rather than the fact that the domain doesn't exist.</description>
      <pubDate>Wed, 11 Jul 2007 05:44:53 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:3cd6808b-77a9-41f3-b7f0-a3d31beafc3e</guid>
      <link>http://crunchlife.com/articles/2007/07/09/expect-the-unexpected-bool-isinrole-string-role#comment-3</link>
    </item>
    <item>
      <title>"Expect the Unexpected: bool IsInRole(string role)" by retsoced</title>
      <description>Maybe you should expect the unexcepted? gah... bad pun.....</description>
      <pubDate>Tue, 10 Jul 2007 18:58:38 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:f73001d5-b995-4074-8c10-50ce89ffe198</guid>
      <link>http://crunchlife.com/articles/2007/07/09/expect-the-unexpected-bool-isinrole-string-role#comment-1</link>
    </item>
  </channel>
</rss>

