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


Top 5 Contributors of the Month
david stephan
Post New Web Links

Changing a users role with RadioButtons (User is always in single role)

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
 
So I have a set of 5 radio buttons corresponding to the roles a user can have on my website.  I have been successfully able to retreive what radio button needs to be checked for the role the user is currently in... string username = Request.QueryString["username"]; // Get Access Levels and populate radio buttons. if (Roles.IsUserInRole(username, "Banned") == true) { RadioButton4.Checked = true; } if (Roles.IsUserInRole(username, "Member") == true) { RadioButton1.Checked = true; } if (Roles.IsUserInRole(username, "FOB_Employee") == true) { RadioButton2.Checked = true; } if (Roles.IsUserInRole(username, "FOB_Administrator") == true) { RadioButton3.Checked = true; } if (Roles.IsUserInRole(username, "Webmaster") == true) { RadioButton5.Checked = true; } My problem is I do not know what to do with the actual procedure of changing the roles based on the new radio button selection.  I have tried many different methods, including using if statements to check if the user is currently in the role, remove him/her from that roll, and then add the user to the newly selected role.  It appears, from my testing, that you can not


View Complete Post


More Related Resource Links

Need help with setting up SQL Server 2008 for role/user management

  

I've posted my problem in a few other categories.  Sorry for that.  I didn't see the security category until now.

I'm trying to use ASP.NET's built-in role/user management for a couple ASP.NET MVC 2 sites.  I'm using the MVCMusicStore as my guide.  I click on the Configuration Tool as the tutorial suggests, which launches the site administration page.  Unfortunately when I click on the security tab, I get an error that it cannot connect to the data store.  Attempting to test the AspNetSqlProvider gives me a similar error.

I've run the aspnet_regsql program as the error message suggested, and I have a role/user management database ready to go on the server.  The proper tables are constructed, and all that.  The configuration tool still doesn't see the data store.

As a test, I ran the MVCMusicStore demo in the debugger.  Its role/user management functionality worked.  I was able to add myself as a customer, and add/remove items from my cart with no errors or exceptions.  However, when I attempted to access its security tab in the configuration tool, I received the same error as I get for my own project.  How is it possible that role/user management works, but the configuration tool cannot change its settings?

Any suggestions on how I can get the configuration t

Custom Role Provider Not Authenticating Users

  
I have created a custom role provider that is hard coded to say everyone is in a certain group (code below).  I have edited the webconfig of Central Admin, my Web Front End, and the Claims Service.  I can sucessuflly log in using the asp.net membership provider and configured access to the site by adding the "custom" role to the Owner Group.  With all of the above items setup I can launch visual studio and attach the to IIS process and verify that my custom role provider is being called.  Even with all this setup I cannot get another forms based user to be able to access the site.  The other user is getting a sharepoint access denied issues. Any Ideas?   public class IdBasedRoleProvider : RoleProvider { public const string AllAuthenticatedUsersRoleName = "custom"; public override string ApplicationName { get; set; } public override string[] GetRolesForUser(string username) { return new[] { AllAuthenticatedUsersRoleName }; } public override bool RoleExists(string roleName) { if (roleName == AllAuthenticatedUsersRoleName) return true; else return false; } #region Methods Not Implemented public override string[] GetAllRoles() { throw new NotImplementedException(); } public override bool IsUserInRole(string username, string roleName) { throw new NotImplementedException(); } public override void Ad

asp.net,c#,user role and rights,menu

  
hi friendsi want to develope general code or module or structure of web application wich handle multiple user ,their role and right, and according to their rights and role menu will be display.so i can integreate it in any website. kindly provide me solution for asp.net 3.5,C# working environment, and sqlserver 2005 environment.what is the structure for database? i want only one database not asp.net database. can i make login control type assembly(dll)?how?Thanking you 

Need to set "ValidateRequest" on the basis of user role

  
I am trying to implement a code which will switch Validation request on the page on the basis of user role. If accessed by power user, it should allow html entries in textboxes otherwise restrict. I want to implement something like below..I would really appreciate if proper idea/code is shared. if (Page.IsPostBack == false) { if (Session["userrole"].toString()="admin" { SetValidateRequest(false); // Sample Function to set validation } else { SetValidateRequest(true); // Sample Function to set validation } }  

infopath 2003 user role error

  
hi, i'm trying to create a user role for my form in infopath 2003. but when i add a user and click on the icon next to the texbox it gives me this error: The program cannot open the required dialog box beacause no locoation can be found

user mapping to a database and role membership to that database

  
When assigning a 'user mapped Login' to a database and role membership to that database, is it redundent to check/enable db_datareader, db_datawriter as well as db_owner or will check/enable db_owner become all that is necessary to provide role membership to the database?

user role on sharepoint custom list

  
hi, can i set up a user role for a custom list form in sharepoint services 3 i want to use the "submit new absence" form. but i need to modify the form in a way that when a user open the form it fills the user his name or login name in the fields. and that the approver or "assigned to field" also is filled with the approvers name. i think i need to use a query for that, but how can i apply it to the fields of the absence list form

Problem with users needing sysadmin server role to connect to db

  
When we create a new user in SQL Management Studio 2005 and give it just the public server role, it does not allow us to connect to the db. We found that we had to give it the sysadmin server role in order to allow it to connect to the db. We are using a UDL file in order to test connect. It seems that this is true for all users we create in SQL Management Studio 2005. Is there a way where we can change it so that users are not required to have the sysadmin server role in order to connect to a db? We would like it so that if they have at least the public server role, they should be able to connect to the db.

CreateUserWizard creating dupicate user while assigning Role.

  
protected void CreateUserWizard1_CreatedUser(object sender,  EventArgs e){Roles.AddUserToRole((sender as CreateUserWizard).UserName, "Customers");} CreateUserWizard is creating dupicate user while assigning Role.How can we assign Role without duplicating user record? I've observed ApplicationID for assigning Role is Differenent than Creating New User, so when ever Role assigning comes in, it creates  same user again with new UserID. Is it related to Web.Config in some way? As when I try to create user from "VisualStudio/Website/ASP.net Configuration" even then two users with same usernames are entered in aspnet_users with Different ApplicationID and UserID. One user has Role and another duplicate user is without Role status of IsApproved=1.Please help me to resolve this issue.Thanks!  

Creating users with a role

  

Hi, i'm programitcally creating user using theSqlMembershipProvider. I am able to create users however now I want to be to assign them to a certain role once they are created.  How do I go about assigning the newly created user to a role? 

 

CODE to create user, works fine:

 protected void btn_createUser_Click(object sender, EventArgs e)
    {
       
            MembershipCreateStatus createStatus;

            //create some code here that compares the first password and confirm password

            MembershipUser newUser = Membership.CreateUser(tbox_user.Text, tbox_password.Text, tbox_email.Text, lbl_passQuest.Text, tbox_passwordAnswer.Text, true, out createStatus);

            switch (createStatus)
            {
                case MembershipCreateStatus.Success:
                    lbl_resultsOfCreate.Text = "user Created";
                    break;

                case MembershipCreateStatus.DuplicateUserName:
                    lbl_resultsOfCreate.Text = "User name already exists";
                    break;

                case MembershipCreateStatus.DuplicateEmail:
                    lbl_resultsOfCreate.Text = "This email address is already in use";
                    break;

                case MembershipCreateStatus.InvalidEmail:
                    lbl

ScaffoldTable(false) if user is not in the admin role.

  

Hi guys,

I my dynamic data application, I made ScaffoldTable(false) on some of the table in a seperate partial classes. I am using linq to sql classes for my tables and Also I am using sql membership on my application.

what I want to do is that I need to make the following table's ScaffoldTable as false, if the user is not in the admin role. How can I do that ?

thanks.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Configuration;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Xml.Linq;
using System.Linq.Expressions;
using System.Reflection;

/// <summary>
/// Summary description for CategoriesPhoto
/// </summary>

[MetadataType(typeof(CategoriesPhotoMetaData))]
[ScaffoldTable(false)]
public partial class CategoriesPhoto
{
}
public class CategoriesPhotoMetaData
{ 

}





Restrict user with sys admin role to execute a query

  

Hi All

 

I want to restrict  a user with sys admin server role to execute a query. or is there any possibility to drop the query before it get executed (after parsing). I know i can do this using SSMS SET NOEXEC ON | OFF in Query Analyzer.

But how can i implement this when ever sysadmin user executes a particular query.

 


Mohd Sufian www.sqlship.wordpress.com Please mark the post as Answered if it helped.

Issue trying to remove user from role that is no longer available.

  

Using tutorials and some examples of handling membership permission on our site, i have a page that was built using examples found in those pages.. Anyway, now that it is all setup and working ran into first issue.. If a role is setup with a space in the name like this ("Read Only") then you get an error when you try to add someone to that role. But if i change it to be ("ReadOnly") it works fine and no issues..

 

                        <asp:GridView ID="GridViewRole" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSourceRoleObject"
                            DataKeyNames="RoleName" CellPadding="3" CellSpacing="3" AllowPaging="True">
                            <Columns>
                                <asp:CommandField ShowDeleteButton="True" DeleteText="Delete Role" />
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:Button ID="Button1" runat="server" CausesValidation="false" Width="500px" OnClick="ToggleInRole_Click"
                                            Text='<%# ShowInRoleStatus( (string

Adding user to SSAS server role not working

  

I have SQL Server 2005 SP3 installed on  Windows 7

 

 I’m trying to deploy a SSAS project and get the message

 

“Either the user, Ron-laptop\ron, does not have access to the analysis services Project2 database, or the database does not exist”

 

Following recommendations in the forum I’ve used SSMS to view the properties > security of the SSAS connection and am trying to add myself to “The server role is used to grant server-wide security privileges to a user” role

 

How to redirect logged in user based on role

  

Hi!

I want to know how can i redirect a user to a different page when he tries to access a page restricted to another role?

The scenario is as follows:

 I have a folder "Gestao" that only allows users in role "Administrator"

    <system.web>
          <authorization>
            <!--<allow roles="Administrators"/>
        <deny users="*"/>-->
          </authorization>
    </system.web>


If an anonymous user tries to access that folder he is redirected to the login page, but if a logged in user whose role is "friend" tries to access this folder he is also redirected to the login page. I want to redirect him to a page showing a message that he has no permission to access that page/area.

How can I do that? Should i have code on the Page_load event of the login page checking the user role and then redirect him to the correct page? Or is there some otherway to do this?

Thanks in advance!
Rui Palhinhas

 


How can we show certain no of dimension only for two different users having different role in a sing

  

hello,

well i might be having a security problem so i just want to know that can we show certain dimension to one user say  (i.e 10dimension for A user and 15 dimension for B user having different user role in a single cube.)

Please any one help me out soon and give some ideas...so that i can solve my issue ,can we solve this issue naa.. :( ..!!!

Thanks 

Anil Maharjan


redirects to default page if user doesn't have appropriate role

  

Hi All,

 

How to redirects to default page if user doesn't have appropriate role in particular forms Using Asp.net authentication.

 

Thanks in Advance

Shabbir


Categories: 
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