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:

C# - GetRolesForUser Tries To Get Roles On Old Username?

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

C# - Roles.GetRolesForUser(); Returns Blank?

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

Security :: Accessing Username / Password / Roles In Xml File

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

Security :: Roles.AddUserToRole((sender As CreateUserWizard).UserName "Customers"); Not Active

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

Security :: Roles Not Working When Launched?

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

Security :: GetRolesForUser By User Id?

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

Security :: Get Roles Working - User To Be Able To Login And The System Recognize?

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

Security :: Membership Roles Not Working After Move From Computer To Web Server?

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

Security :: How To Hide Multiple Roles With Roles.getallroles()

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

Security :: Update Username Of Current Logged Username?

Mar 12, 2010

How to update username of current logged username?

View 10 Replies

Security :: Automatically Assigning Roles / Standard Practice For Assigning Roles To Newly Signed-on members?

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

To Implement Code Access Security, And URL Based Security Using The Roles & Types?

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

Extending RoleProvider GetRolesForUser ()

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

Security :: How To Get Roles After Login

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

Security :: Is There A Way To Set Up 2 Tiers Of Roles

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

Security :: Specify Roles While New Registration?

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

Security :: Create Roles In Asp?

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

Security :: Associate App With Roles?

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

Security :: Membership Roles In MVC Asp 3.5?

Mar 1, 2010

Pls explain the Membership Roles in MVC ASP.NET 3.5

View 1 Replies

Security :: How To Use Roles In Views

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

Security :: Login To Different Pages With Different Roles?

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

Security :: Redirecting Based On Roles C#?

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

Security :: Redirecting Different Roles WITH Password?

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

Security :: How To Assign Two Roles For One User

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







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