Site Map Data source

Posted on 2007-11-16
Last Modified: 2013-11-07
When I setup my sitemap in, how can I define within the site map that this particular menu should only be displayed if the person is logged in?

And in roles="*", what are the other possible values? How does that work?
Question by:Starr Duskk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 16

Accepted Solution

McExp earned 500 total points
ID: 20300610
you would need to use Membership to control what the user has access to and then the SiteMap Menu will be security trimmed acordingly.

See the extract below from my web.config

      <location path="admin/Gallery">
                        <allow roles="adminPhotos"/>
                        <deny users="*"/>

The above will only allow users who are in the role adminPhotos access to the area ~/admin/Gallery. All other things in the site (asp:Menu etc) will automatically security trim.
LVL 16

Expert Comment

ID: 20300634
How are your users logging into the site do you use Forms Auth?

I should have said you need to use Membership and RolesProviders and a Secured SiteMap, see bellow for another snip from my web.config

            <membership defaultProvider="AccessMembershipProvider">
                        <add name="AccessMembershipProvider" type="Samples.AccessProviders.AccessMembershipProvider" connectionStringName="ASPNetDB" enablePasswordRetrieval="false" enablePasswordReset="true" requiresUniqueEmail="true" requiresQuestionAndAnswer="false" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" applicationName="RAdmin" hashAlgorithmType="SHA1" passwordFormat="Hashed"/>
            <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="AccessRoleProvider">
                        <add connectionStringName="ASPNetDB" applicationName="RedsAdmin" name="AccessRoleProvider" type="Samples.AccessProviders.AccessRoleProvider"/>
            <siteMap enabled="true" defaultProvider="SecuredSiteMapProvider">
                        <add name="SecuredSiteMapProvider" description="Default SiteMap provider." type="System.Web.XmlSiteMapProvider " siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>

As you can see I use the Access provider, if you are using Sql Server your code will differ slightly. However the concert still applies.

Author Comment

by:Starr Duskk
ID: 20301490
well, I guess I'll have to take your word for it, since I can't test it at this point. :)

LVL 16

Expert Comment

ID: 20301650
As an alternative to this you can show/hide menu items in the Databound event of the asp:menu. in this you can use "User.Identity.IsAuthenticated" and you wouldn't need any of what I have suggested above. If you need more info, ask and I'll find the solution I have provided to others before.

Author Comment

by:Starr Duskk
ID: 20302230
Okay, I"ll open a new question. thanks!

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question