Security :: Roles.GetRolesForUser(UserName) Not Working?
Oct 26, 2010
Roles.GetRolesForUser(UserName) .I have follwing codes in my Web.config,
<authentication mode="Forms">
<forms slidingExpiration="true" defaultUrl="admin/Welcome.aspx" timeout="60"/> </authentication>
<roleManager enabled="true" defaultProvider="SecurityTutorialsSqlRoleProvider">
<providers>
<add name="SecurityTutorialsSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" applicationName="SecurityTutorials" connectionStringName="SecurityTutorialsConnectionString"/>
</providers>
</roleManager>
View 2 Replies
Similar Messages:
Mar 24, 2010
I have a section on a page where a user can change their username. This is basically the code for that:
user.UserName = txtNewUserName.Text;
user.Save();
user is a class in my dbml and Save calls SubmitChanges on the data context.The name is changed in the database, so when it calls the following method, it fails because it is trying to get the user with the old username instead of the one that is in the database now.
public override string[] GetRolesForUser(string username)
{
return dc.Users.Where(u => u.UserName== username)
.SingleOrDefault().Roles
.Select(r => r.RoleName).ToArray<string>();
}
View 1 Replies
Dec 18, 2010
using asp.net membership api when I call Roles.GetRolesForUser(); it returns nothing. When I make a call Roles.GetAllRoles() all the roles are returned. What is the problem? Also what is the correct way to authenticate users using the membership api?
View 2 Replies
Aug 26, 2010
Currently I am storing my username and password (passwordFormat="SHA1") credientails in my web.config. I would like to figure out how to access them in an xml file that I have stored in my App_Data directory rather than the web.config file because I do not want my application restarting everytime I manually add a user (small list of 5 authorized users for the CMS section).
Here is what my web.config section looks like:
<authentication mode="Forms">
<forms name=".Administration"
loginUrl="~/SiteAdmin/Default.aspx"
defaultUrl="~/SiteAdmin/Administration/Default.aspx"
protection="All"
timeout="30"
path="/"
requireSSL="false"
slidingExpiration="true"
enableCrossAppRedirects="false"
cookieless="UseDeviceProfile"
domain="">
<credentials passwordFormat="SHA1">
<user name="username" password="474BA67XXXXXX3B36DFD8A7BED6C85B04943" />
</credentials>
</forms>
</authentication>
View 1 Replies
Feb 8, 2010
Do you know where could come from my issue. In deed every time i create an user "customers" I always have to active it in asp.net configuration.
View 2 Replies
Nov 5, 2010
I launched an aspx site recently and all roles worked perfectly in the development environment.
However when I use the login function in the production environment all users have access to all pages. Why would this be happening?
View 3 Replies
Aug 23, 2010
Why there is no method to get user roles by their ID. I do not want to use name. So I'm just wondering do I have to write my own or somebody else already did it ?
View 11 Replies
Apr 22, 2010
I have a sitemap of 5 items. 2 items i only want the admin to see. I want the user to be able to login and the system recognise who it is and if an admin, bring up the 2 items in the sitemap. If not an admin, hide the items.
View 3 Replies
May 21, 2010
i have been creating a website on my computer which has VWD 2008 and SQL Server 2008, i have membership and role system set up, (using the aspnet_regsql) and that worked perfectly fine on my compuetr.
Now when i was ready to deploy it on my web server, i simply copied the whole database, and added it onto the SQL Server on my server, so it has exactly the same rows, tables, data, etc etc.
Now, when i run the website via the domain, users are able to login etc, and my authentication code that redirects users if they are not logged in also works, so im sure it cant be a problem with the membership provider, as it all seems to work.
But all the users that were already in the set roles, it still shows them in the role in aspnet_roles table, but its not working, the thing i have in the roles loginview does not display, and even after running the web administrator tool, it shows that the user is in that role, but does not work (even while viewing on the local machine)
So i added code in a page_load event that would auto add that user to the role
System.Web.Security.Roles.AddUserToRole(HttpContext.Current.User.Identity.Name, "TestRole");
and on entering the domain (on the local server) i got error:
The role '' was not found.
And on local host server
I get error:
The user 'TestUser' is already in role 'TestRole'.
But yet, even on the localhost i still cant see any indications that the user is in a role, as none of my rle login views are showing.
The role '' was not found.
View 5 Replies
Mar 7, 2011
I have a multi level application that I am developing and need to block multiple rows from being joined. I know how to hide one role but I cannot figure out how to hide multiple.
Here is my current code
[Code]....
View 2 Replies
Mar 12, 2010
How to update username of current logged username?
View 10 Replies
May 17, 2010
Newb question: what is the standard practice for assigning roles to newly signed-on members. Is it usually manual or is there a way of automatically assigning roles. Being completely new to this, I am confronted by the issue of my site having three different roles that new members could fall into, but am unsure about how to assign each a role. I can't imagine having to go through the process manually if I have thousands of members.
View 6 Replies
Apr 24, 2010
[ASP.NET 3.5, FormsAuthentication, SQL Server]
In the Roles table there is Role, and RoleType.
I have 3different roles, 2 of which have sub-roles.
Example
Role----------------------Type
Adminstrator
Subscriber---Basic
Subscriber---Business
I need to implement Code Access Security, and URL based security using the roles & types...
For instance, the (Subscriber/Basic) would need to view a different set of pages, and have different access to things then a (Subscriber/Business).
I think I can handle the Code Access security with a custom attribute, but I am unsure to how enforce a User be apart of 2 roles in the URL Authorization.
I am currently using the web.config to deny/allow access to the directories/pages.
e.g.
/Areas/Admin/web.config
[Code]....
Is it possible to force the user to be apart of 2 roles with this technique?
View 1 Replies
Jun 3, 2010
The GetRolesForUser() method in the RoleProvider takes the user login name and returns the list of roles for that user. But in my application this is not enough, I need a few more pieces of information to be able to get the user's roles. How can I get this extra information into the method? I have it in the Session, but I found out that Session is not available in the RoleProvider.
What I had in mind was putting this extra info in some class that extends MembershipUser, assuming I can get to it inside the RoleProvider. But I don't know how to create the CustomMembershipUser and make it part of the MembershipProvider. Is this even possible? The easy way out would be using cookies, but I'm trying to keep away from it.
View 1 Replies
Jan 7, 2010
I have used .net login control to authenticate user,i have three types of role ,role1,role2 and role3 and i have users and user have different roles.
now my requirement is like as per loggedin user i want to redirect user on particular page as per role.
for example if loggedin user role is role1 than he will redirect default1.aspx
for example if loggedin user role is role2 than he will redirect default2.aspx
for example if loggedin user role is role3 than he will redirect default3.aspx
and one question if same user may be have more than one role than what should happen???
I got a solution for same than if we are used "loggingin" event than it would be possible but i had placed login control in login view anonymous template because as per my requirement i want that after successfull login user can't see login control on page.thats why i didn't get the login control event on code.
View 6 Replies
Mar 22, 2010
In our system now, we have a class of user and beneath each class, there's a type of user.
Is there a way to setup and use the ASP.Net role provider with this kind of setup?
View 2 Replies
Feb 20, 2010
i am new to asp.net, i am creating a small website for my college, in that.
Only the admin's can create other users...
Now while using the nw registration wizard, i hav to mention the role also in that page.
View 5 Replies
Jun 10, 2010
can any one tell how to create the roles in asp.net? when ever Admin creates the roles, there it self he should assing the pages,which pages should be open when ever perticular person enters in to the site. When ever Admin wants to assing the Roles,all pages appear in grid view with check box,if he checks that pages,he able to access other wise he couldnot access that page.
View 1 Replies
Aug 3, 2010
i want to create a webservice that reading from the user identity interacts with a db, where there are app names and group that can use that app, and gives to the user a list of operation that he can use.
My question is, is there any table in apsnetdb that does this association or i should create a costum table.
View 1 Replies
Mar 1, 2010
Pls explain the Membership Roles in MVC ASP.NET 3.5
View 1 Replies
Feb 27, 2011
I know how use Roles in Controller:
[Code]....
In this situation, any one who is not "admin" can'nt vist the "About.cshtml". But what if I want anonymous can see part of the "About.cshtml"?
[Code]....
I know code above is wrong, But how can implement my goal in Views
View 2 Replies
May 18, 2010
I have created 3 different folders (admin, user, viewer) in my site and each has a different template (masterPage). I created user and roles which are admins, users, and viewers. I assigned each role to a user in .Net administration Tool.
What I need to do is to allow each user to access his page only and deny access to others , except for the admin who can access all pages.
View 4 Replies
Oct 5, 2010
I'm trying to redirect users upon login based on their roles which were defined in the Administer website feature of asp.net.Heres what I'm trying protected void Login1_LoggedIn(object sender, EventArgs e)
View 2 Replies
Oct 7, 2010
Im trying to redirect different roles to different pages. Its working but the code I'm entering allows people through even with incorrect passwords. protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
View 1 Replies
Jan 11, 2010
Im now in assigning a roles to a user. But, 1 of my user wants me to assign 2 roles for him.. The situasion is like this :
I have a few roles which are :
- zone head
-zone officer
-clerk
The problem is now 1 person can be assign for 1 role only..
How can i assign 2 roles for 1 user..
View 4 Replies