Change a page based on a user's profile.

Posted on 2008-11-03
Last Modified: 2013-12-17
I am looking for best practices or a solution on how to change a page based on a logged in users profile.  I am able to authenticate users against our LDAP and pull their group membership information, however, what is the best way to change the page based on their group membership information.  For example, I have a set of buttons, and only certain user groups should see certain buttons.  I am not sure of the best way to proceed.  My application is written in C# with a SQL server back end.  

Question by:shanemay
    LVL 7

    Accepted Solution

    Use trimming principles.  Here you can find some good help about trimming based on the user's roles, rights...
    This time tracker has trimming enabled and it is just perfect for what you want to do...

    Download them and try it.  
    LVL 6

    Expert Comment

    I'm not sure how C# exactly works but with principle couldn't you simple use variables and change their data with an SQL query?

    I mean structure the page as you would. Perform an SQL query with the user id of the logged in user or through the url. Put some variables in the page and set their data to that of your query.

    Sorry if this is completely useless to you, or doesn't make much sense.
    LVL 7

    Expert Comment

    This is VB code but surely gives you a baseline to start on your c# code.  You might ask in their forums to see if they have the c# version.  

    Overall will let you control what you want users to see based on their permissions and roles.
    LVL 4

    Assisted Solution

    I would just have a standard set of buttons on the page and change their visibility in the code behind based on the user's role using a switch or something
    Some of these methods can also be used to ensure that when a user accesses a function they actually have permission to.
    switch (rolename){
    	case "administrator":
    		//show relevant buttons for administrator
    	case "user":
    		//show relevant buttons for user
    		//fall through

    Open in new window


    Author Closing Comment

    Thank you for the feedback and advice.  

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now