Mixed authentication in ASP.NET 2.0 - Roles

Discussion in 'ASP .Net Security' started by Enrico De Majorca, Dec 19, 2006.

  1. Working solution:


    Web Config:

    <system.web>
    <roleManager enabled="true" cacheRolesInCookie="true"
    defaultProvider="WindowsProvider">

    <providers>

    <add name="WindowsProvider"
    type="System.Web.Security.WindowsTokenRoleProvider"
    description="Retrieves roles data from the Windows authenticated token
    for the request"/>

    </providers>

    </roleManager>

    <identity impersonate="true"/>
    <authentication mode="Windows" />
    </system.web>


    Global asax.cs:

    WindowsIdentity ident = WindowsIdentity.GetCurrent();
    WindowsPrincipal princ = new WindowsPrincipal(ident);
    RolePrincipal _RolePrincipal = new RolePrincipal(ident);

    string[] myRoles = _RolePrincipal.GetRoles();
     
    Enrico De Majorca, Dec 19, 2006
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.