.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Do you load content based on Role or Username?

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net



I want to load content depending on what "Permissions" the user has that is currently logged in.


Lets say i have a bunch of links, do i load the links based on the username or based on their role?


ie.) i want links 1 2 3 to appear if role/username is "Admin" and i want link 1 to appear if role/username is "User"


Do i load based on if(User.Identity.Name == "Name") or do i do something similar with roles?





View Complete Post

More Related Resource Links

Unique content within master page based on conditions met


 Hi all-

I would like to present users with unique content based on certain conditions being met as they land on the home page (default.aspx).  The condition logic will be in the VB code behind Page Load event. The content will go in a content placeholder as specificed from the master page. 

However, the content change wouldn't be something small (ie making a panel or label visible or not) but rather it will be different HTML,  Divs and databound gridview content.  The HTML content will be stored in the database.

Can someone point me in the right direction for best practices on how to accomplish this?


Problem making Role based Menu in MVC application



 I want to make Rolebase menu in MVC such that if user doesnot have permission for some action then that Action name shouldnot be shown in the Menu.

 I have used the code in the url(http://forums.asp.net/t/1566328.aspx) in my MVC application.My application is a Discussion Forum(in MVC) same functionality as in this forum forums.asp.net

 I have used Controllers for post, thread etc.In each controller there are some actions that are using [Authorize(Roles)] attribute

 but this coding does not count  those Actions in Controllers having Authorize attribute according to the url http://forums.asp.net/t/1566328.aspx 

 In the code, Authorize attribute is applied to Controller class, but my requirement is of Applying Authorize attribute to some actions in controller so that some are available for all users and  some links are available rolewise.Now what is the solution for that?



Test-Driven Design: Using Mocks And Tests To Design Role-Based Objects


Use Test-Driven Development with mock objects to design object oriented code in terms of roles and responsibilities, not categorization of objects into class hierarchies.

Isaiah Perumalla

MSDN Magazine June 2009

Authorize It: Use Role-Based Security in Your Middle Tier .NET Apps with Authorization Manager


Authorization Manager in Windows Server 2003 represents a significant improvement in the administration of role-based security, making it more scalable, flexible, and easier to implement. Using Authorization Manager, you can define roles and the tasks those roles can perform. You can nest roles to inherit characteristics from other roles, and you can define application groups. In addition, Authorization Manager lets you use scripts to modify permissions dynamically, and it allows you to wrap your security logic in a security policy that can be stored in Active Directory. Authorization Manager also includes an easy-to-use API for running access checks. The author discusses all of these topics and demonstrates them with a working sample.

Keith Brown

MSDN Magazine November 2003

Security: Unify the Role-Based Security Models for Enterprise and Application Domains with .NET


Role-based security allows administrators to assign access permissions to users based on the roles they play rather than on their individual identities. These privileges can be used to control access to objects and methods, and are easier to identify and maintain than user-based security. The .NET Framework provides two role-based security models, which are exposed as two namespaces: System.Enterprise-Services and System.Security.Permissions. Presented here is a comparison of the two options and a discussion of when each is the right choice. The author also demonstrates the process involved in setting up access security and discusses role memberships.

Juval Lowy

MSDN Magazine May 2002

Content deployment: pages not based on a page layout

Is it possible to use content deplyoment feature when pages (in page library) are not based on a Page Layout?

external content not load in page like style and js in asp.net mvc when i use area


i am working on a asp.net mvc 2 website who have a area and i have a problem with them.

i use different different url routing for application settings. i have two folder called style

first folder location in main directory  /Style/style.css

second folder location in Area area/style/style.css

everything is work fine in application but when i used style.css from main directory in my area's views then style not worked. when i track them from firebug then i got error "The resource could not be found" but path is correct.

sombody tell me to use absolute path to solve this issue. how i can use absolute path to declare resource url in views.

any suggestion , sollution on this issue who can help me to solve this issue.

require guideline for 'Role-based authentication/authorization'



In my asp.net website in VS-2005 with SQL-Server 2005 as db, I need to implement role-based Authentication/Authorization.

I am familiar to the practises used in role-based authentication..as I have previously worked on projects that used this method. However, my project lead used to design the database. Now I have an existing website where authentication has been set to anonymous by setting 'allow users="?"' in the authentication tags in web.config.

If I use the createUserWizard control and use the Membership.creatUser(.....) method in code behind will the asp.net security tables, like users, roles, userinrole etc get created on its own? Can anyone please give the proper steps on how to acheive this?

Getting filtered data from Role based SSAS security

Hi everyone,I've got a heap of reports that are based on various SSAS cubes. I have roles defined on these cubes that restrict data via certain dimensions. Question is, will these restrictions filter through to the report...ie, if I have a sales person restricted in the SSAS cube to only see sales against their territory (restricted in the Territory dimension), when they run the report will it filter the result based on their SSAS credentials and only show the data they have access to (even though the SSRS report has no direct filters or parameters applied)?Cheers for any help!!

Load content to the page with in XML?

I'd like to find out about the best technique to generate multiple container boxes/thumbnails of the content with xml that are loaded into wrap panel. It can be stackpanels or listboxes with textblocks and checkboxes in them. Any sample or helpful source of information is highly appreciated. Thank you in advance.

Want to page content based off of a character limit or height of container

First of all I would like to say hello. I have created a backend that allows me to update my site content. I am using fckeditor to pull the data from my table in the database. The problem I am having is this:  I need to create paging of content so that when the height restriction is met a next btn or numbering system displays to allow the user to click to the next page of content. Can anyone point me in the right direction or possible tell me how I can do this?

SP 2010 Form Based Authentication username begins with "i:0#.w|"

Hello there! For the life of me, i can't figure out why SharePoint keeps putting the phrase "i:0#.w|" infront of everyones username / accounts. Both on mysite and portal sites. A quick bing search revelaed that i am not the only one: http://fangdahai.blogspot.com/2010/06/i0w-is-still-there-in-sharepoint-2010.html. Anyone have a solution to fix this annoying problem? Thanks!

can't get role based authorization to work

My problem is that my service will not start regardless of what I put in the Role demand.  I even try "BUILTIN\Users" or "Users". Basically, there is absolutely no scenario where the out of the box WCF functionality actually works.  So what magic do I have to do to enable Authorization to check if the authenticated identity has a specific domain group membership? <system.serviceModel> <bindings> <netTcpBinding> <binding name="RBSync" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536"> <reliableSession ordered="true" enabled="true" /> <security mode="Transport"> <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/> </security> </binding> </netTcpBinding> </bindings> <client /> <behaviors> <serviceBehaviors>

Sharepoint 2010 with role-based asp.net security


I have a Sharepoint 2010 (forms authentication) site on windows server 2008 with asp.net role-based security. At the highest level i have document libraries with folders within each as shown below.

> Doc Lib 1

>> Sub folder 1

>> Sub folder 2

> Doc Lib 2

>> Sub folder 1

>> Sub folder 2

Sub folder 1 and sub folder 2 are the same within each document library.

I want to be able to use asp.net roles to restrict users access to the document library. For example, user 1 should only be able to access sub folder 1 within doc lib 1. I'm not sure how i should go about configuring the roles.

I have created role1 for access to doclib1 and role2 for doclib2. In addition i also have roleA for access to subfolder1 and roleB for access to subfolder2. I have assigned the roles the libraries and folders. To user 1, i have assigned : role1 and role A. I expect that user1 should only see doclib1 and within it subfolder1. But that isn't the case.

How do i achieve my desired results?

Role Provider mess up Welcome [username] on wss


Hi,I have a role provider, and this is how i wrote for my GetRolesForUser(string username), now the problem is on the wss page, on the top right corner, it shows Welcome "System Account" Instead of the logged in user. And I checked it, after RunWithElevatedPrivilage, The CurrentUser is System Account,How can I make the welcome to show the current logged user?

Thank you

public override string[] GetRolesForUser(string username)
      //string[] s = ws.GetRolesForUser(username);
      //return s;
      List<string> domainGroups = new List<string>();
      var webContext = SPContext.Current.Web;


          using (SPSite site = new SPSite(webContext.Site.ID))
            //siteEval = site.OpenWeb(site.

Creating Content Type in a Hub and creating lists based on this content type



I am building a prototype of a Sharepoint app and I am new to this technology. We have a need for a piece with News items. Someone comes to a sharepoint site and adds a news piece there. This news content piece needs to be approved and to do that approver goes to a staging environment where they can see this news post in proper context (of how it would look in production) and can approve it. If they reject it, news piece never gets propagated to pro environment which also subscribes to this content type.  What I did was I created content type hub with a "News" content type in a Content Type hub and subscribed other sites to this hub. I can see this content type in subscribing sites.

I have following questions regarding this problem:

- Is it the right architecture for such a task?

- I am trying to create a list which would manage adding and editing of news items but I can't find any option to bind a custom list with content type, I can add site columns to a list but I am not able to base a list on a content type.

Thanks for your input.

Listformwebpart misbehaving for folder-based content types


I created a number of folder content types, adding several metadata fields to the default content type.  I then created multiple document libraries that use those content types (as well as custom document content types).  I did not customize any of the forms.  All was well.  I then saved my site as a template, and created some new sites from that template.

Now weird stuff started to happen.  For one of my content types, the "new" form lost the custom metadata fields.  When making a new folder of this type, the form looks the same as the new form for a vanilla folder.  But once it is created, both the "edit" and "display" forms displayed all the fields correctly.

For another content type, I got the opposite behavior.  The "new" form shows all the custom metadata fields, but the "edit" form only shows the vanilla folder fields.  The "Display" form is fine.  I can even pull up the Display form, verify that all the expected fields are there, click the Edit button, and watch the form shrink to the reduced-field size.

It is as if the listformwebpart is selectively failing to acknowledge that the content type it is dealing with is anything other than Folder.

To summarize:

  • The original site I built works fine, but a
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend