"The trust relationship between this workstation and the primary domain failed" exception from IsInRole
Blog Date: 7/13/2009
userIsInRole =
HttpContext.Current.User.IsInRole(windowsSecurityGroupName);
IPrincipal p = new GenericPrincipal(User.Identity.Name, string[] names);
protected void Application_AuthorizeRequest()
{
// Validate only html requests, not css or javascript
if (HttpContext.Current.Request.AcceptTypes != null
&& HttpContext.Current.Request.AcceptTypes.Length > 0
&& HttpContext.Current.Request.AcceptTypes[0].Equals("text/html"))
{
if (User.Identity.IsAuthenticated)
{
//var roles = new SecurityRoles[]
// { SecurityRoles.UserSegmentRead, SecurityRoles.UserSegmentWrite };
var roles = new String[] { "MailingRead", "MailingWrite" };
System.Web.HttpContext.Current.User
= new System.Security.Principal.GenericPrincipal(User.Identity, roles);
}
}
}
<system.web>
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider"/>
</systen.web>
7/14/2009 1:21:55 PM
|