Results 1 to 29 of 29

Thread: [RESOLVED] Show menu item according to user's rights

  1. #1

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Resolved [RESOLVED] Show menu item according to user's rights

    Hi,
    I'm a newbie in Web applications and I'm experimenting with Master pages in ASP.NET 2.0 with VS2005. I've created a menu in master page that wiil be used throught the application. I want to show menu Items according to logged user's profile. If he is admin then all menu item and if other than admin then according to given rights. Is this possible, if yes then how??
    Please guide me,
    Thanks in Advance
    Using .NET 3.5 (VS 2008) And XP SP2

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Show menu item according to user's rights

    Yes. Easy. I assume you are using ASP.NET 2.0.

    ASP.NET 2.0 has a menu control, which you can point at an XML file. Create a separate XML file for each of the 'ranks' among your members. In the Master Page, check for the value of the session variable, which should contain the rank. Or whatever your mechanism is. Then according to the rank, point it at the corresponding XML file.

  3. #3

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    Thanks mendhak for reply.
    Could you send me any xml file and how to connect it to my menu control.
    Thanks again
    Using .NET 3.5 (VS 2008) And XP SP2

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Show menu item according to user's rights


  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    Hello Bajrang,

    The fact that you are using ASP.NET 2.0 makes this very easy!!

    I am going to assume that you have used the built in User/Role Manager within VS 2005, and that you have set up an Administrators Role within the Website | ASP.NET Configuration Section.

    Having done that, simply drag and drop a Menu from the Navigation Sub Menu in the Toolbox onto the form, and also a SiteMapDataSource. You should also put on a login control (maybe put this in a LoginView) and maybe a LoginStatus as well.

    Point the datasource of the Menu Control at the SiteMapDataSource and then add a sitemap to your project by right clicking on the project, add new item, SiteMap and fill it with something like the following:

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
        <siteMapNode url="Default.aspx" title="Test"  description="">
            <siteMapNode url="Admin/Test1.aspx" title="Test1"  description="" />
            <siteMapNode url="Test2.aspx" title="Test2"  description="" />
        </siteMapNode>
    </siteMap>
    Next, add a folder to the project and call is Admin, and then create the a Page within this folder called Test1.aspx, and add another page to the route of the Project called Test2.aspx.

    Having done that, you then need to add the following to your web.config file:

    Code:
        <globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
        <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
          <providers>
            <add name="XmlSiteMapProvider" description="SiteMap provider which reads in .sitemap XML files." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="web.sitemap" securityTrimmingEnabled="true"/>
          </providers>
        </siteMap>
        
        <authentication mode="Forms">
          <forms cookieless="AutoDetect" loginUrl="~/Default.aspx" name="WTWFORMAUTH" protection="Validation" timeout="300"/>
        </authentication>
      <location path="Admin">
        <system.web>
          <authorization>
            <allow roles="Administrators"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
    Now, with all of that done, when you run the website, you should see that initially there is only one entry in the Menu, called Test2, but when you log in with someone who is a member of Administrators, then you will see two entries and you will be able to navigate to that page.

    It seems like quite a lot of work, but once you have done it a couple of times, you will soon get the hang of it!!

    Hope this helps!!

    Gary

  6. #6

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    Thanks gep13 for your valuable information, but I am confused now,
    I created three category for login in my database, and all three logins have different rights.I've created three diff. xml files but don't know how to bind these xml files to my menu control. Should I have a dataset and fill according to category and then bind to Menu or anything else.
    Please guide me
    Thanks again
    Bye
    Using .NET 3.5 (VS 2008) And XP SP2

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    Hello,

    I think there has been some confusion between the methods that we are employing.

    Are you using the built in user access database and login controls that ship with VS 2005, or are you using your own way of authenticating to the website?

    Gary

  8. #8

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    Thanks gep13,
    yes sir, I am using access database where I've assigned diff. rights for diff. users. I am not using login controls.
    Its not a web site my application, its an intranet app where few users can access it and each user has an ID n Password.
    Its a simple application. Hope you get it.
    As I told in my first post that I am very new to It. So Iam very confused
    bytheway thanks and hoping some solution fromyou.
    Using .NET 3.5 (VS 2008) And XP SP2

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    Hello again,

    The method that I described will only work if you are using the built in controls and user providers that ship with VS 2005. Since you are not using this approach then I am not really going to be able to help you as I have not really played with what you are describing.

    Mendhak, can you offer any other suggestions?

    Sorry I can not be any more help on this!!

    Gary

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Show menu item according to user's rights

    You can use a database. You can use an XML file.

    Here's how to do it with an XML file, from codeguru.com

    Code:
    private void CreateMenuWithXmlFile()
    {
      string path = @"C:\MyXmlFile.xml";
      DataSet ds = new DataSet();
      ds.ReadXml(path);
      Menu menu = new Menu();
      menu.MenuItemClick += new MenuEventHandler(menu_MenuItemClick);
    
      for (int i = 0; i < ds.Tables.Count; i++)
      {
        MenuItem parentItem = new MenuItem((string)ds.Tables[i].TableName);
        menu.Items.Add(parentItem);
    
        for (int c = 0; c < ds.Tables[i].Columns.Count; c++)
        {
          MenuItem column = new MenuItem((string)ds.Tables[i].Columns[c].ColumnName);
          menu.Items.Add(column);
    
          for (int r = 0; r < ds.Tables[i].Rows.Count; r++)
          {
            MenuItem row = new MenuItem((string)ds.Tables[i].Rows[r][c].ToString());
            parentItem.ChildItems.Add(row);
          }
        }
      }
    
      Panel1.Controls.Add(menu);
      Panel1.DataBind();
    }
    Now, all you need to do, is create three separate XML files, one for each of your roles. More if there are more roles. Based upon the role of the user who has logged in, load the corresponding XML file and follow the same procedure.

    A more efficient way would be to store all your menu items in the database itself, and each menu item corresponds to a role. So for example, Role A might have item1,item4,item5,item6, while Role B might have item1,item2,item3, item 5. You will load the dataset based upon the role from the database, and then, here's more code from codeproject.

    Code:
    private void PopulateMenu()
    {
      DataSet ds = GetDataSetForMenu();
      Menu menu = new Menu();
    
      foreach (DataRow parentItem in ds.Tables["Categories"].Rows)
      {
        MenuItem categoryItem = new MenuItem((string)parentItem["CategoryName"]);
        menu.Items.Add(categoryItem);
    
        foreach (DataRow childItem in parentItem.GetChildRows("Children"))
        {
          MenuItem childrenItem = new MenuItem((string)childItem["ProductName"]);
          categoryItem.ChildItems.Add(childrenItem);
        }
      }
    
      Panel1.Controls.Add(menu);
      Panel1.DataBind();
    }

  11. #11

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    Thanks Mendhak
    I tried your method but ds.Tables.Count is 0 so nothing is happening,
    Probably something is wrong with xml file using your method.
    I tried other option also that is Web.siteMap and it is working fine( in case of single user) but I think this Web.sitemap must be only one in our project. So what would happen if multiple users will access my application.
    Actually I m creating Web.sitemp after user's login and I 've diferent xml files for those profile, I just copied that xml file to Web.sitemp and its working. So
    everytime user logins, the Web.sitemp is updated. So I am worry about mutiple users case.
    Can you help me out. Thanks again
    Bye
    Last edited by Bajrang; Apr 24th, 2007 at 05:26 AM.
    Using .NET 3.5 (VS 2008) And XP SP2

  12. #12
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    Hello,

    Unless i am missing something, which I more than likely am, then I think you are over complicating this.

    The way I see this is, you would have one web.sitemap, and this would detail all the available menu items, i.e. the entire hierarchy. Then using the web.config file, you would configure access to these pages/folders as shown earlier. This may involve having multiple roles, and multiple users can belong to multiple roles.

    Once this is set up, then the menu items will change dynamically, based on who is logged in at any time.

    Please correct me if I have missed something.

    Thanks

    Gary

  13. #13

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    Thanks Gary,
    As I've not tested it on multiple machines, so I am afraid.
    But as I run different Instances of application for different user profile on the same machine , its working fine and Web.sitemap is changed according to logged user(Last one).I checked it, web.sitemap is modified according to last looged user.
    I think once menu is bind to web.sitemap , it doesn't affected even if web.sitemap is changed for that specific user. Am I Correct?
    Thanks Again
    Last edited by Bajrang; Apr 24th, 2007 at 07:36 AM.
    Using .NET 3.5 (VS 2008) And XP SP2

  14. #14
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    Again, I am not sure I fully understand what it is exactly you are doing. I have only ever used 1 web.sitemap, and this has worked well in all the situations I have used it.

    I can't say for definite what happens if you then start adding "new" web.sitemap for different users. I still don't understand why you need to load different site maps, can you give an example of the different site maps you are trying to use?

  15. #15

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    example of the different site maps.
    I choose one of three xml files according to logged users(Operator, mgmtstaff,storekeeper) then I copy all contents of that xml file to Web.sitemap file . Now, I think, you will get it. Have a look and suggest me what improvement is possibe there. Thanks

    1. Operator.xml
    vb Code:
    1. <?xml version="1.0" encoding="utf-8" ?>
    2. <siteMap>
    3.  <siteMapNode url="Default.aspx" title="Home">
    4.    <siteMapNode title="Entry" description="Entry">
    5.       <siteMapNode url="Transactions.aspx" title="Transactions" description="Transactions" />
    6.    </siteMapNode>
    7.    <siteMapNode title="Update" description="Update">
    8.       <siteMapNode url="UpdateMaterialMaster.aspx" title="Material Master" description="Material Master" />
    9.       <siteMapNode url="UpdateVendorMaster.aspx" title="Vendor Master" description="Vendor Master" />        
    10.       <siteMapNode url="UpdatePriceMaster.aspx" title="Price Master" description="Price Master" />
    11.       <siteMapNode url="UpdateLocationMaster.aspx" title="Location Master" description="Location Master" />
    12.       <siteMapNode url="UpdateStoreMaster.aspx" title="Store Master" description="Store Master" />
    13.       <siteMapNode url="UpdateRackMaster.aspx" title="Rack Master" description="Rack Master" />
    14.       <siteMapNode url="UpdateTransactions.aspx" title="Transactions" description="Transactions" />
    15.    </siteMapNode>
    16.    <siteMapNode title="View" description="View">
    17.       <siteMapNode url="ViewMaterialMaster.aspx" title="Material Master" description="Material Master" />
    18.       <siteMapNode url="ViewVendorMaster.aspx" title="Vendor Master" description="Vendor Master" />      
    19.       <siteMapNode url="ViewPriceMaster.aspx" title="Price Master" description="Price Master" />
    20.       <siteMapNode url="ViewLocationMaster.aspx" title="Location Master" description="Location Master" />
    21.       <siteMapNode url="ViewStoreMaster.aspx" title="Store Master" description="Store Master" />
    22.       <siteMapNode url="ViewRackMaster.aspx" title="Rack Master" description="Rack Master" />
    23.       <siteMapNode url="ViewReports.aspx" title="Reports" description="Reports" />
    24.    </siteMapNode>
    25.  
    26.  </siteMapNode>
    27. </siteMap>

    2. ManagementStaff.xml
    vb Code:
    1. <?xml version="1.0" encoding="utf-8" ?>
    2. <siteMap>
    3.  <siteMapNode url="Default.aspx" title="Home">
    4.       <siteMapNode title="View" description="View">
    5.       <siteMapNode url="ViewMaterialMaster.aspx" title="Material Master" description="Material Master" />
    6.       <siteMapNode url="ViewVendorMaster.aspx" title="Vendor Master" description="Vendor Master" />      
    7.       <siteMapNode url="ViewPriceMaster.aspx" title="Price Master" description="Price Master" />
    8.       <siteMapNode url="ViewLocationMaster.aspx" title="Location Master" description="Location Master" />
    9.       <siteMapNode url="ViewStoreMaster.aspx" title="Store Master" description="Store Master" />
    10.       <siteMapNode url="ViewRackMaster.aspx" title="Rack Master" description="Rack Master" />
    11.       <siteMapNode url="ViewReports.aspx" title="Transactions" description="Reports" />
    12.    </siteMapNode>
    13.  </siteMapNode>
    14. </siteMap>

    3. Storekeeper.xml
    vb Code:
    1. <?xml version="1.0" encoding="utf-8" ?>
    2. <siteMap>
    3.  <siteMapNode url="Default.aspx" title="Home">
    4.    <siteMapNode title="Entry" description="Entry">
    5.       <siteMapNode url="EntryMaterialMaster.aspx" title="Material Master" description="Material Master" />
    6.       <siteMapNode url="EntryVendorMaster.aspx" title="Vendor Master" description="Vendor Master" />         
    7.       <siteMapNode url="EntryLocationMaster.aspx" title="Location Master" description="Location Master" />
    8.       <siteMapNode url="EntryStoreMaster.aspx" title="Store Master" description="Store Master" />
    9.       <siteMapNode url="EntryRackMaster.aspx" title="Rack Master" description="Rack Master" />
    10.       <siteMapNode url="EntryTransactions.aspx" title="Transactions" description="Transactions" />
    11.    </siteMapNode>
    12.    <siteMapNode title="View" description="View">
    13.       <siteMapNode url="ViewMaterialMaster.aspx" title="Material Master" description="Material Master" />
    14.       <siteMapNode url="ViewVendorMaster.aspx" title="Vendor Master" description="Vendor Master" />      
    15.       <siteMapNode url="ViewPriceMaster.aspx" title="Price Master" description="Price Master" />
    16.       <siteMapNode url="ViewLocationMaster.aspx" title="Location Master" description="Location Master" />
    17.       <siteMapNode url="ViewStoreMaster.aspx" title="Store Master" description="Store Master" />
    18.       <siteMapNode url="ViewRackMaster.aspx" title="Rack Master" description="Rack Master" />
    19.       <siteMapNode url="ViewReports.aspx" title="Reports" description="Reports" />
    20.    </siteMapNode>
    21.  </siteMapNode>
    22. </siteMap>
    Using .NET 3.5 (VS 2008) And XP SP2

  16. #16
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    So, why can you not combine all three files into one sitemap?

    You obviously have three roles:

    Operator
    Manager
    StoreKeeper

    Operator have access to:
    Entry
    Update
    View

    Management have access to:
    View

    StoreKeeper have access to:
    Entry
    View

    So the way i would do this is to store all the Entry files in a folder called entry, all the Update files in one called update, and all the view files in a folder called view. Then in the web.config files, restrict access to these folders. i.e.

    view folder - operator, management, storekeeper
    update folder - operator
    entry folder - operator and storekeeper

    Unless I am really missing something, i don't see why this would be a problem. All you need to do is to create the correct roles within your application, and then add users into the roles which they are a member of.

    Hope this helps!
    Last edited by gep13; Apr 24th, 2007 at 08:14 AM. Reason: roles were wrong

  17. #17
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    Just to add as well, you can restrict access to an individual file as well, not just files that are in a folder i.e.

    Code:
    <location path="AddEditPost.aspx">
        <system.web>
          <authorization>
            <allow roles="Administrators,Editors,Moderators,Posters" />
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
    Cheers!!

  18. #18

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    Thanks a lot.
    AS you told I created a single xlm file that has all rights.
    So the way i would do this is to store all the Entry files in a folder called entry, all the Update files in one called update, and all the view files in a folder called view. Then in the web.config files, restrict access to these folders
    As I told I am newbie in ASP.NET, I didn't get what you have done in AddEditPost.aspx, so please suggest how can change my web.config file for these users.Thanks Again
    Have a look on this file IS it correct according to you?
    vb Code:
    1. <?xml version="1.0" encoding="utf-8" ?>
    2. <siteMap>
    3.  <siteMapNode url="Default.aspx" title="Home">
    4.    <siteMapNode title="Entry" description="Entry">
    5.      
    6.       <siteMapNode url="EntryMaterialMaster.aspx" title="Material Master" description="Material Master" />
    7.       <siteMapNode url="EntryVendorMaster.aspx" title="Vendor Master" description="Vendor Master" />         
    8.       <siteMapNode url="EntryLocationMaster.aspx" title="Location Master" description="Location Master" />
    9.       <siteMapNode url="EntryStoreMaster.aspx" title="Store Master" description="Store Master" />
    10.       <siteMapNode url="EntryRackMaster.aspx" title="Rack Master" description="Rack Master" />
    11.       <siteMapNode url="EntryTransactions.aspx" title="Transactions" description="Transactions" />
    12.    
    13.    </siteMapNode>
    14.    <siteMapNode title="Update" description="Update">
    15.       <siteMapNode url="UpdateMaterialMaster.aspx" title="Material Master" description="Material Master" />
    16.       <siteMapNode url="UpdateVendorMaster.aspx" title="Vendor Master" description="Vendor Master" />        
    17.       <siteMapNode url="UpdatePriceMaster.aspx" title="Price Master" description="Price Master" />
    18.       <siteMapNode url="UpdateLocationMaster.aspx" title="Location Master" description="Location Master" />
    19.       <siteMapNode url="UpdateStoreMaster.aspx" title="Store Master" description="Store Master" />
    20.       <siteMapNode url="UpdateRackMaster.aspx" title="Rack Master" description="Rack Master" />
    21.       <siteMapNode url="UpdateTransactions.aspx" title="Transactions" description="Transactions" />
    22.    </siteMapNode>
    23.    <siteMapNode title="View" description="View">
    24.       <siteMapNode url="ViewMaterialMaster.aspx" title="Material Master" description="Material Master" />
    25.       <siteMapNode url="ViewVendorMaster.aspx" title="Vendor Master" description="Vendor Master" />      
    26.       <siteMapNode url="ViewPriceMaster.aspx" title="Price Master" description="Price Master" />
    27.       <siteMapNode url="ViewLocationMaster.aspx" title="Location Master" description="Location Master" />
    28.       <siteMapNode url="ViewStoreMaster.aspx" title="Store Master" description="Store Master" />
    29.       <siteMapNode url="ViewRackMaster.aspx" title="Rack Master" description="Rack Master" />
    30.       <siteMapNode url="ViewReports.aspx" title="Reports" description="Reports" />
    31.    </siteMapNode>
    32.  
    33.  </siteMapNode>
    34. </siteMap>
    Using .NET 3.5 (VS 2008) And XP SP2

  19. #19
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    Yes, that web.sitemap looks fine.

    Now in terms of what you need to do within the web.config file...

    I will assume that following:

    1. You have created three folders within the root of your application, entry, view and update
    2. You have assigned three roles to your application, Operator, Manager, StoreKeeper

    Your web.config needs to be modified to include following (as per post #5 above):

    Code:
    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
          <providers>
            <add name="XmlSiteMapProvider" description="SiteMap provider which reads in .sitemap XML files." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="web.sitemap" securityTrimmingEnabled="true"/>
          </providers>
        </siteMap>
        
        <authentication mode="Forms">
          <forms cookieless="AutoDetect" loginUrl="~/Default.aspx" name="WTWFORMAUTH" protection="Validation" timeout="300"/>
        </authentication>
      <location path="entry">
        <system.web>
          <authorization>
            <allow roles="Operator,StoreKeeper"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
      <location path="update">
        <system.web>
          <authorization>
            <allow roles="Operator"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
      <location path="view">
        <system.web>
          <authorization>
            <allow roles="Operator,Manager,StoreKeeper"/>
            <deny users="*"/>
          </authorization>
        </system.web>
      </location>
    So here i have added three "location" nodes to the web.config file, one for each folder, and I have assigned Roles to each to these folders.

    Hope this helps!!!

    Gary

  20. #20

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    Thanks a lot, You've done a lot of work for me.
    Excellent!. I understand now,but I still have one problem that what should I do those folder.Should I put those different xml files for diff. users? If yes then what should be name of files.
    If not then please let me know.
    Thanks a lot
    Using .NET 3.5 (VS 2008) And XP SP2

  21. #21
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    Hello,

    I am still not sure if you understand the concept! Using this approach, you do not need to use different XML Files.

    I will put an application together for you tonight if I get a chance tonight, and i will let you see what I mean.

    Gary

  22. #22

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    Okay,Gary
    Thanks a lot for your kind support.
    You are really a helpful person.
    Using .NET 3.5 (VS 2008) And XP SP2

  23. #23
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    I would wait and see if I can get it to work for you first!!

  24. #24
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    Hello again,

    Please find attached a very basic application which shows you the menu action that you requested (well at least my interpretation of it!! )

    I found a slight problem with the sitemap that you had, in that you need to have a url for each sitemapNode, otherwise the menu does not work properly.

    To start with, only the "Home" Menu item is visible because no one is logged in.

    You can log into the site using the following username and password combinations:

    UserName Password
    manage manage1#
    operate operate1#
    store store1#

    As you log in which each different user, you should see that the menu items that are available change, and also that users are not allowed to browse directly to the link either, but rather they just come back to the same page and are prompted for a user name and password of a user who has access to that page.

    Hope all of it makes sense, if not feel free to post any questions.


    Gary
    Attached Files Attached Files

  25. #25

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: Show menu item according to user's rights

    Thanks a lot, Gary
    I helped me very much.
    Now I got the whole things,
    Bye, Thanks again
    Using .NET 3.5 (VS 2008) And XP SP2

  26. #26
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Show menu item according to user's rights

    No probs!

    Remember to mark your thread as resolved if you think it is closed out, and if you are so inclined then you can rate my post.

    Cheers

    Gary

  27. #27

    Thread Starter
    Hyperactive Member Bajrang's Avatar
    Join Date
    Oct 2006
    Posts
    309

    Re: [RESOLVED] Show menu item according to user's rights

    Hi,
    One more question How can I insert Seprator between menu items using web.sitemap. and also how can align Menu item to left, currently they are central aligned.Thanks Again for your valuable information,
    Have a good Day,
    Bye
    Last edited by Bajrang; Apr 27th, 2007 at 01:51 AM.
    Using .NET 3.5 (VS 2008) And XP SP2

  28. #28
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] Show menu item according to user's rights

    You can specify separatorimageurl for your menuitems.

  29. #29
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: [RESOLVED] Show menu item according to user's rights

    Hi Gep13, can we use your code website2.zip also with Windows Authentication mode?
    Thank you
    Thanks a lot for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width