Expect the Unexpected: bool IsInRole(string role)
Posted by Ryan Baxter Tue, 10 Jul 2007 02:34:00 GMT
Running some tests yesterday, I was alarmed by an Exception that read, “The trust relationship between the primary domain and the trusted domain failed.” What?!? This code worked a few weeks ago! The method in question called Page.User.IsInRole(“DomainName\RoleName”) to determine if a user was assigned to an administrator’s role. bool IsAdministrator(). Simple and efficient. Why is this happening?!?

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.
Page.User.IsInRole(“DomainName\RoleName”) returns true
Page.User.IsInRole(“RoleName”) returns true
Page.User.IsInRole(“DomainName\TypoRoleName”) returns false
But…
Page.User.IsInRole(“TypoRoleName”) throws the Exception
Huh?
I haven’t had time to dig further into this, but I’d definitely be interested in hearing some opinions.
- Posted in Expect the Unexpected
- Meta 3 comments, permalink, rss, atom
Comments
about 23 hours later:
1 day later:
1 day later:

