views:

750

answers:

1

I am using Windows authentication and don't have a custom membership. However I do have a custom role provider and turned it on. However, what about the < authorization /> element in the web.config? Do I need to do something with that as well?

At the moment I can't get use Roles.GetRolesForUser("") method (returns nothing) but have to do it like Roles.Provider.GetRolesForUser("")?

The biggest problem is with the sitemaps as it doesn't get into the Roles.IsUserInRole method. For the moment I am using a custom xmlsitemapprovider for this but it isn't neat.

I enabled the rolemanager and the set the securitytrimmingenabled to true for the sitemap in the web.config.

+1  A: 

Yes, you need to configure your custom Roles provider in web.config - something like this:

<roleManager enabled="true" defaultProvider="SqlRoleManager">
  <providers>
    <add name="SqlRoleManager" 
         type="System.Web.Security.SqlRoleProvider"
         connectionStringName="SqlRoleManagerConnection"
         applicationName="MyApplication" />
  </providers>
</roleManager>

You should also set security trimming to true, too. eg.

<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
    <providers>
      <add name="XmlSiteMapProvider"
        description="Default SiteMap provider."
        type="System.Web.XmlSiteMapProvider "
        siteMapFile="Web.sitemap"
        securityTrimmingEnabled="true" />
    </providers>
  </siteMap>
Dan Diplo
I described in my question that I had these all set in the web.config. Apparently that wasn't clear so I edited the question and put it in. Sorry but this answer at this moment doesn't help me.
Nyla Pareska