IS AllStars Login
Keywords
Location

"The trust relationship between this workstation and the primary domain failed" exception from IsInRole


Blog Date: 7/13/2009
 

Recent Blogs

<< Back

Windows Authentication Membership Provider 6/29/2009
Microsoft Outlook 2007: Minimize to System Tray 7/5/2009
Mozilla Firefox "Save & Quit" doesn't work 7/6/2009
 More Blogs...

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
Home | Job Search | Career Tools | Blog | Tech News | Contact | Site Map