ASP.NET Redirect User Based On Role?

Jan 23, 2012

I want the app to redirect a user to a different home page depending on their role. Its currently working for 2 users using the following IF?

If Request.IsAuthenticated AndAlso User.IsInRole("Staff") = True Then
Response.Redirect("~/About.aspx")
ElseIf Request.IsAuthenticated AndAlso User.IsInRole("HR") = False Then
Response.Redirect("~/HRHRCompanyNavigation.aspx")
End If

How can I get this to work for more than 2 user roles?

View 1 Replies


ADVERTISEMENT

Asp.net - Redirecting Based On The User's Role?

Nov 9, 2011

i'm having some problem over here..when user enter their id and password,it will show up the main page and its for user but when admin or staff enter their id,it will enter the user's main page and i have to click admin site on the top hyperlink where it automatically logout and once i enter back admin passwrd or staff passwrd then only it redirect to admin page or staff page.how to make it like once user enter their passwrd it redirect to user page and once admin enter admin password or staff enter their password in the login it redirect to admin or staff ?I have 3 roles over here which are admin,staff and user.Hereby i'll provide you my aspx code and also my vb code which is running behind the program.

[Code]...

View 2 Replies

Asp.net - Displaying Part Of Commandcolumn Based On Role?

Apr 14, 2012

I have a page with a gridview. The gridview has "Enable Editing" and "Enable Deleting" checked by default. I want to be able to "uncheck" either of these in the code-behind page_load event.

I found this SO question but this hides the whole commandcolumn. I only want to hide the "Edit" or "Delete" hyperlink based on the role of a user. How would I go about doing this?

View 1 Replies

C# - ASP.NET Directory Access With Role Based Security?

Apr 27, 2011

I have an ASP.Net portal like application with multiple roles. I have placed the subpages of that role in its own directory adding a web config with an authorization allowing only that role. I have css and javascript in the root directory that can not get access inside the protected role folders. How can I allow these folders css/js to have access to all roles. Sorry if this is easy question I have searched but I am rather new to ASP.NET

View 1 Replies

How To Handle Login/logout With Role Based Access

Jun 29, 2011

I have the membership provider setup and its currently pointing to a SQL database on my machine. The role based access works and I have a menu that is security trimmed. The user can only get to pages that they have access to.When an anonymous user tries to get to a page that they dont have access to it brings them to a login page so that they can login. That is fine. But when a logged in user tries to get to a page they dont have access to(Usually by typing in a URL) it brings them to the login page again asking them to login(except there already logged in. I'd like to either take them to a different page or somehow tell them they don't have access.

View 1 Replies

When I Create The User And Assign The Role, The User Should Get The Permission Automatically?

Nov 24, 2011

I need to define some roles in my program with defined permissions. Let's say the administrator can have access only to certain features. The officer in charge to certain features and the user as well. for example, I have several group boxes and the user can access one of it only. So how i do manage these permissions? What I want do is have the roles already with the defined permissions. When I create the user and assign the role, the user should get the permission automatically.

View 6 Replies

Asp.net - Add User To A Role When Registering?

Jan 7, 2012

I have a role called "Customer", I wish to add users who register to be to automatically added to that role. At the moment I can only assign users to roles by using ASP.net Web Site Administration Tool.If it helps: I'm using the default login.aspx and register.aspx files from Account folder in vb web profile.

View 1 Replies

Asp.net - Retrieve The Currently Logged In User Role Name In Textbox ?

Dec 14, 2010

How to retrieve the currently logged in user role name in textbox using vb.net ? iam currently using

TextBox1.Text = Roles.GetRolesForUser(User.Identity.Name)

om page load event but it is highlighted by a blue line in visual studio 2008

View 1 Replies

Asp.net Mvc - Testing User Role Authorize Attribute In .NET?

Jan 23, 2010

I am using ASP.NET MVC to build a site. I am using VB as programming language.I have couple of questions.

1 I have created a role "Manager". How Do I check if a user belongs to this particular role?

For now I am using If My.User.IsInRole("Manager") Then 'Direct to a view Else 'Direct to another view End If Is this the right way? 2 How to use the Authorize attribute to limit access to a Function?

I know in C# it goes [Authorize (Roles ="Manager")] but not sure in VB. Also can I define property to redirect a user who does not have "Manager" role to a particular view when trying to access this function .

View 1 Replies

Disable Nodes In Treeview By User Or Role?

Jun 2, 2011

How to disable node of treeview by user or role in winform

View 10 Replies

ASP.NET Membership Check If User Is In A Role In Custom Class

Jan 17, 2010

In my VS solution, I have two projects.One for the Web Interface, other for DataAcess and BusinessLogic. I know I can check if the currently logged-on user is Employee in Web Interface project like this from the code behind:

Dim isEmployee = User.IsInRole("Employee")

The problem is that I have a Class call UserManagement in my the DA and BL project which I want to check the currently logged-on user role also. I can't use Dim isEmployee = User.IsInRole("Employee") because it doesn't have aspx page.

What do I need to do to check the user role in my custom class?

View 2 Replies

C# - Update User's Role From A Dropdown List Within A Repeater

Jul 5, 2010

I have repeater which shows a list of users and there roles. There is also a dropdown list to chnage there role see below

<td><asp:DropDownList ID="ddlChangeType" class="controlwidth100" runat="server" AutoPostBack="true" OnSelectedIndexChanged="change" /></td>

the change event works but what I need is the ID of the row so the user can be updated.

View 3 Replies

Selecting Rows From Different Tables To Update User Role?

Mar 2, 2012

what i have is 3 text boxes

User
Role
Upgrade To

and a gridview

what i am trying to do is :when i type in the user the system will look in my table cg_security_user and recognise that the current role is "guest". Then in the Upgrade to when i type in "admin" it will update the current role(guest) to admin here is a picture is attached of what i am trying to do as it might paint a better picture the code which i have made so far is

Private Sub cmdupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdupdate.Click
Dim myAdapter As New OleDbDataAdapter
strsql = "update table1 set studname = @field2, studaddress=@field3, studage=@field4 where studid=@field1"

[code]....

View 4 Replies

Populate Text Boxes With Data Based On Redirect From Another Page?

Jun 16, 2011

This task is a little out of my reach so i dont even really know where to start...I want a user to click the command field "select" in my gridview. I then want them to be redirected ( response.redirect()) to an input form that will have its various asp.net text boxes filled with data from that selected item. I also need the ability to do this logical process:

IF the form is loaded from user
selecting item in gridview THEN
''Populate controls with data from selected gridview item Else Load

[code].....

View 1 Replies

Asp.net - Show Failure Text If The Loggedin User Role Not Found?

Apr 9, 2011

How to display login failure text if user logging in user role id differ than vendors role ... i m using the following code to authenticate user role during logging in

[Code]....

View 2 Replies

Redirect Unauthorized User To A Login Page?

Mar 19, 2010

I have my own login page.If any user access any page directly(without login),i want to redirect unauthorized user to login page. Using Generic Handler is there any chance?

View 2 Replies

VB Web Service - Redirect The User When Their Session Is Active?

Mar 15, 2012

I created a function that allows me to login to my web service. I created a session here and added some values I retrieved from a stored procedure.[code].....

My question is: I have a default.aspx and a master page, how can I redirect the user when their session is active? For example, the default page tells users that access is forbidden untill the login/register.Do I have to use the form load handler for default.aspx or the masterpages' load handler? How do I check weither the usersession is active?

View 1 Replies

Asp.net - Validate User Role During Login Button Click Event In Login Control?

Apr 9, 2011

I have a login control in my asp.net webform i uses the roles manager...i have two roles admin and vendors i want when user enter username and password in login control then on login button click event it validates either the user is admin or vendors if vendor is admin then it will redirect to default.aspx other wise stay on login page with error. ...how to do this using vb.net ?

View 1 Replies

My.User.IsInRole("Role Name") Throws A Trust Relationship Error On Windows 7

Dec 10, 2009

Problem: My programs throw a Trust Relationship error when calling My.User.IsInRole() but only on Windows 7 64 bits. They work on all our Windows XP stations. My code is pretty simple.

With My.User
if .IsInRole("Some Security Group Name") Then
Bla.. Bla.. Bla..
End If
End With

I'm the only one in the company using Windows 7 which we are evaluating to decide if/when we're going to upgrade all our PC's. I am a domain administrator and my PC is in the domain and I'm authenticated. Since I installed Win 7 I haven't had any other authentication issues. The apps are built on .NET 2.0 SP2 I don't know much about our domain setup which is handled by our network administrator but I'm told that the Primary Controller is a Windows 2003 and the Secondary is Windows 2000. He tells me that by default every workstation first authenticate on the Secondary controller if it's available.

Here's the StackTrace

System.SystemException was unhandled
Message="The trust relationship between this workstation and the primary domain failed.
" Source="mscorlib"
StackTrace:

[code]....

View 2 Replies

Asp.net - Auto-redirect On Login Link Click To Admin Page If User Already Logged In

Apr 9, 2011

i have a login page link above the page /// i want if user already loggedin then anybody click on loginlink then the user will automatically redirect to default.aspx ..

View 3 Replies

Asp.net - Auto-redirect User To Default.aspx If They Directly Access Any Page Of Website?

Feb 28, 2011

I have the following pages structure in my asp.net 3.5 website ...i want if anybody directly access any page of my site as [URL] then it will automatically redirected to [URL] How to do this using vb.net, asp.net

View 2 Replies

Get User's Location Based On IP?

Jun 22, 2010

I want to get the user's approximate location (down to like a 1km radius) by their IP. Is this possible in VB Express 2008?

View 4 Replies

Execute Based On Inputs From User?

Mar 3, 2009

I'm not sure the best way to accomplish this, what i have is 10 checkboxes on a form named chkbox1 to chkbox10, say ther user selects 4 then clicks a button, i was wanting to execute code one after each other like[code]...

View 3 Replies

Get The User Name Based On Login Id From The Same Database?

Apr 10, 2012

how to display the user name based on successful login id i have one database table name: UserMark in the table:

UserId
UserLogin
Password
Fullname
SurveyId

i have login.aspx page which required me to enter login id and password, if sql success, it will redirect the page to home.aspx however, at the home. aspx page required to display the full name based on login id.i place the code on login button

Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
strSQL = "SELECT LoginID FROM UserMark WHERE LoginID='" & oCommon.FixSingleQuotes(txtEmail.Text) & "' AND Pwd='" & oCommon.FixSingleQuotes(txtPassword.Text) & "'"

[code]....

View 2 Replies

If/then Based User And Password Authentication?

Apr 17, 2009

I am writing a program that accepts a user name and password (the password must show up as *s). The user gets three tries to enter the correct information before the program is closed. So far I have the password showing up as the password in clear text the first time and in *s the next two times. The authentication also fails even when I use the correct user name and password which are password and user for now.

Public Class frmPassword
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Static intCounter As Integer = 0
intCounter = intCounter + 1

[code].....

View 5 Replies

C# - Match SQL Columns Based On User Input?

Jan 24, 2011

What i am trying to achieve is that there are 7 columns in my db table. one is primary key and rest 6 are integer columns. Now my application will allow user to input 6 values. I want to compare 6 values entered by user to those 6 integer columns and if in any row 3 or more columns match user's input Primary key of that table is returned..I have tried using queries, cursor, nested loops and i am still unable to achieve my results..

UPDATED :DB Table Structure.. I am inputting 2,3,7,11,45,65. Number of returned rows should be 5. eg..

UID A1 A2 A3 A4 A5 A6
-----------------------
1 2 3 4 5 6 7
2 2 3 4 55 56 57
3 65 11 45 66 67 68

[code]....

IDs returned should be 1,3,4,9,10

View 5 Replies

Choosing An Array Based On User Input

Dec 8, 2009

I have 10 constant arrays of data that can be used throughout the program.[code]I also have an array that needs to be populated randomly depending on user input.array_user(8)If the user selects 3 for instance...I need the data in array_user to be populated by the data in array03.I know I can do that with if/then statements...but I'm sure there is a much simpler way to do it.

View 1 Replies

Fill Datatable Based On User Input

Apr 20, 2012

I have a SQL db that holds the records for my page. On my page I have a details view I want to populate with records from my db. I can populate the records just fine, I need to be able to populate in records based on a user selection from a drop box?To clarify, on my main page I have a drop down list with years (ie. 2011, 2010, 2009), and a drop down containing account codes (ie. six-digit numbers). Based on what the user chooses for the year (for example 2010) and the what they choose for the account code (for example 123456) I want to populate the details view (which is on a seperate page) with only those records from 2010 and with the account code 123456??

View 1 Replies

Open Second Form Based On User Input?

Apr 14, 2009

I am working on a project using Visual Studio .NET 2003.I am trying to open a second form based on user response to Yes/No Message Box. I have tried two different code variations. The first variation is:

Dim MsgAnswer As Boolean
MsgAnswer = True
Dim MsgRes As DialogResult
Dim CustomerInfo1 As New Form

[code]....

With this code I get an exception error: An unhandled exception of type 'System.NullReferenceException' occurred in OrpheyOnOpen.exe Additional information: Object reference not set to an instance of an object.

View 6 Replies

Restict The Input Of A User Based On What The System Needs?

Oct 6, 2011

how to restict the input of a user if im going to accept account e.g.,

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved