Security :: How To Redirect Logged In User Based On Role
Nov 25, 2010
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"
[Code]....
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?
View 2 Replies
Similar Messages:
Mar 17, 2011
i want to redirect the user after the log in based on his role. e.g. admin, userI already read the other threads.. I already used this:
[Code]....
And this:
[Code]....
I also tried the above codes on the Page_Load event.
View 7 Replies
Apr 22, 2010
I'm not sure if this is possible or not, I'm using Roles to limit what pages a user can access based on there assigned Role. My question, is there anyway to redirect the user to a specific web page based on thier role after they login.
For example:
If Bob logs in with Role="Automotive", I want him to be redirected to Auto.aspx.If sue logs in with Role="Clothing", i want her to be redirected to cloths.aspx.
View 8 Replies
Dec 8, 2010
I am trying to create a web application that shows a list of events for different users. I have 2 different user 'roles': admin and member.
Is there a way of getting the current logged in users role? i have tried:
[Code]....
But it doesnt seem to be catching the certain user types, it always shows all of the events.
View 4 Replies
Mar 25, 2010
In my website i am creating a custom FormsAuthentication ticket during log in. This ticket stores the userid but i also need to specify the role of the logged in user. How do i do it?
View 2 Replies
Feb 4, 2010
I have a login form from the membership and I am trying to make it so that it would redirect depending on role. I have tried to put this code under login1_loggedin but it didn't seem to work. how can I do this?
View 1 Replies
Apr 8, 2010
i want to interlink between 2 applications of mine.. suppose a user has logged in one of my application and me store his username and password in cookies...nd nw i want to use those values in the cookies to log-in in other website without entering the username and password again for the other website. i mean to i want to skip the login page of other website.
protected void btnclick_Click(object sender, EventArgs e)
{
HttpCookie username = new HttpCookie("UserName", "a");
HttpCookie password = new HttpCookie("Password", "a");
Response.Cookies.Add(username);
Response.Cookies.Add(password);
Response.Cookies["UserName"].Expires = DateTime.Now.AddHours(1);
Response.Cookies["Password"].Expires = DateTime.Now.AddHours(1);
}
this is the code for storing values in cookie on click of a button. nw in 2nd application on page load i am using this code.
HttpCookie userName = Request.Cookies.Get("UserName");
HttpCookie password = Request.Cookies.Get("Password");
if (userName != null && password != null)
{
if (Membership.ValidateUser(userName.Value, password.Value))
{
FormsAuthentication.RedirectFromLoginPage(userName.Value, false);
}
}
here m able to get the username nd password but don't how to validate that username and password so that i can skip the login page of this application..m not sure about the code in BOLD above if its rite or worng.. and for Login i am using ASP login Control
in both applications.
View 3 Replies
Feb 24, 2011
I'm trying to allow logged user who are in department XYZ to perform some task for my third party App. I have two SQL tables named Users & UserList. The third party app (GoldMine) graps the USERNAME from the Users table and store it as UserID which I then referecnce SessionID. The UserList table has two columns (GM_UserName & Department) which I'm interested in. When a user login into the 3rd party app (GoldMine), i then compare the USERNAME (from Users table) to GM_UserName (from UserList table) and see whether GM_UserName is in = 'Dept XYZ'. Take a look at the SQL query below.
sqlDept = "SELECT USERNAME FROM Users LEFT JOIN UserList ON UserList.GM_UserName=Users.UserName WHERE UserList.Department ='Dept XYZ'"
I'm able to do this.
If Session("Userid") = "TestUser1" Or Session("UserID") = "TestUser2" Then Do this Else Do that End If
BUT unable to do this...
If user's Department = 'Department XYZ' Then
Do This
Else
Do that
End IF
View 2 Replies
Aug 17, 2010
I want to execute some logic if the Logged in User can view a page "~/MyPage.aspx". IF the logged in user should be elligible to view the page is determined by the role based security I configured in the web.config file. There are many methods to find out if the user is in role XXX or not. But I did not find any method to find out if the user can view a page or not ahead of transferring the user to that page. Maybe I will hide a link to a specific page to the logged in user if the user is not elligible to view that page if I know the technique i am asking here to know.
View 1 Replies
Feb 18, 2011
I am creating a interface for User Role Management based on built in membership provider.I want to display all the roles as check boxes for a selected user. I am able to display all the roles in the database, but not able to load the specific user roles. For example, I am able to publish role 1 role 2 role3 role 4 as check boxes. But if the user is already flagged as role 1 and role 3, I am not able to show that data (role1 and 3 should be checked when form loads, but right now, they are not checked)...How do I get the roles as checked boxes display on a page.I am using a repeater control to display roles as check boxes on the page..
<asp:Repeater ID="UsersRoleList" runat="server">
<ItemTemplate>
<asp:CheckBox runat="server" ID="RoleCheckBox" AutoPostBack="true" Text='<%# Container.DataItem %>'
[code]...
View 1 Replies
Jan 26, 2010
i am using asp.net membership. when users arrive at my sight they can enter user name and password.
I then want to redirect them to a page called "MyAccountPage.aspx" which is unique to them. could someone post the c sharp code that I can use to capture the Unique Id of the user is it best to then pass this as a parameter to a control on the aspx page that displays data for that user. am I correct in thinking that I need a UserId column in my data table as well.
View 1 Replies
Sep 12, 2010
I am using Formsauthentication. My situation is as per below:
the login form has codebehind :
protected void LoginButton_Click(object sender, EventArgs e)
{
TextBox uname = Login1.FindControl("UserName") as TextBox;
TextBox pass = Login1.FindControl("Password") as TextBox;
CheckBox rm = Login1.FindControl("RememberMe") as CheckBox;
Literal fail = Login1.FindControl("Literal1") as Literal;
if (Membership.ValidateUser(uname.Text, pass.Text))
[Code].....
Now the problem is that when I try to login with proper credentials it first redirects to default.aspx( there is no such page in my project), after login again with same credentials it properly redirects to the correct page. Why such problem arises? to fix this?
View 6 Replies
Dec 25, 2010
I am using a XMLSitemap to show my menu. In my menu I have a node "Log in". But I only want to show this to the visitors who are not logged in. (Not to everyone like what the "*" does). Is there a rolename for those visitors or something like that?This is my XML SiteMap
[Code]....
View 2 Replies
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
Jan 9, 2011
I am trying to get the role of the user which just logged in the website. I am doing this:
string userRole = Roles.GetRolesForUser(LoginUser.UserName).ToString();
but that returns 'System.String', not the real role :(.
What am I doing wrong?
P.S. LoginUser is the login control
View 1 Replies
Oct 27, 2010
I have implemented role based security in my asp.net 2.0 vb.net application using windows authentication and the windowstokenroleprovider and limiting access to certain pages using the location tag to specific active directory groups.
The issue is that when a user tries to access a page they are not authorized to view it brings up a login prompt and when it does not pass it takes them to the default page that tells them they are not authorized to view the page. I am wondering if there is a way to throw up a custom page that tells them they are not athorized to view the page that I can incorporate into the site itself with the header and so forth? if this page could come up in lieu of the sign in box popping up as well.
View 2 Replies
Jun 6, 2013
I have table called ROLE with fields (id,name,permission) example values (1001,madhu,hr)
I have another table called LOGIN with fields(id,DOB,password) example values(1001,24101989,madhukumar)
What i want is , if i login using the LOGIN table ,it check the id and permission in the ROLE table , if the permission is 'hr' it enable to access the menu , or if the permission is any other it just print the error message ("no permission")
Note: menu is placed in master page , but login is not in the master page ...
View 1 Replies
May 9, 2010
I want to display a menu (which will be strongly typed with it's own unique model) across all pages only if a user is logged in.What menu items are available depend on the user's role and also I'll need to hit the repository to get numbers like "x Messages", etc
Been scratching my head for a simple solution here. Don't want to create something that need changes all over the place.All my controllers derive from a BaseController, all my Models from BaseViewModel....probably where I'll be implementing functionality for this.
View 3 Replies
May 7, 2015
I have LOGIN PANEL for student, and I want to disable it in different page. And only the admin can enable and disable it. I dont know the logic behind here.
View 1 Replies
Apr 2, 2010
In the web.config file i have put some code in so that when users log in they will be re-directed to another part of the website which only registered users can access. for the admin part only the admin can log in and it takes him to the admin section and that works fine. it is only this that is causing me problems.
the code i inserted for which the user needs to be diverted to is:
<location path ="UserLoggedInFindUs.aspx">
<system.web>
<authorization>
<deny users ="?"/>
[Code]....
View 2 Replies
Jul 11, 2010
How to implement role based security in each page.
View 2 Replies
Mar 15, 2010
Right now, I have all the employees of my company login to an external website using the company id, username and a password. We are trying to integrate it into an intranet portal which should provide seamless access to this website without requiring the user to enter these credentials.
Is there any way of doing this programmatically (.NET C#)? Very similar to screenscraping, Can I simulate the appropriate POST action and then redirect the user to the logged in page?
View 3 Replies
Oct 25, 2010
How can I implement role based security that would show the admin tab if the user was logged in as a admin by using (ul-li) like the below code as a simple example. I do not want to use the menu control is this possible ?
<ul>
<li><a href="#">Services</a></li>
<li><a href="#">About us</a></li>
<li><a href="#">Admin</a></li>
</ul>
View 3 Replies
Jan 4, 2010
I am building an ASP.NET 3.5 Web Application and I am NOT using the membership provider for security. In the application I have a role named Admin and all the files for this role are inside the Security folder in the project. Currently for all the pages inside the security folder I am checking to see if the logged in user's role is an Admin or not. This to me seems very redundant, can do something like "If the user is requesting a page inside the security folder then check his role".
View 1 Replies
Mar 21, 2011
How to access datas based on user roles in asp.net ? For example : i have two admins (admin1, admin2). In the frontend ,admin1 has full access to datas(view,add,edit,delete all datas) while admin2 has limited access to datas(view,add,edit,delete certain datas alone and not all datas)
View 2 Replies