Home > Not Working > Asp.net Isuserinrole Not Working

Asp.net Isuserinrole Not Working

Contents

As for "Context.User.IsInRole", it uses the Context.User class instance(when you enable role manager, it is an instance of RolePrincipal class), and this class will cache roles and the IsInRole method will Taking just the query string from a URL in a log file Do you still gain the magical benefits of a shield when wearing but not wielding it? C++ implementation of Hackerrank's "Maximum Element in a Stack" Is there any point in ultra-high ISO for DSLR [not film]? If there is further explanation need, do let me know i will explain further. –EM923 Jan 27 '15 at 8:49 add a comment| 1 Answer 1 active oldest votes up vote http://sohohosting.net/not-working/asp-net-roles-isuserinrole-not-working.html

Here's my code extract private void RedirectToPage() { ///checks the role of the logged in user and redirects to appropriate home page bool IsSuperadmin = Roles.IsUserInRole(loginMain.UserName, "Superadmin"); bool IsAdmin = Roles.IsUserInRole(HttpContext.Current.User.Identity.Name, How to plot a simple circle in LaTeX more hot questions question feed lang-cs about us tour help blog chat data legal privacy policy work here advertising info mobile contact us Hotels on the Las Vegas strip: is there a commitment to gamble? Is correct Name of previous Identity? –Mark Shevchenko Jan 27 '15 at 16:20 Yes authentication type is equals to forms by using string ".Equals" method, but still its not http://forums.asp.net/t/1347471.aspx?Roles+IsUserInRole+not+working

User.isinrole Not Working

User.IsInRole is giving the correct response when used in other code in the project. SQL Server...) instead of the RolePrincpal class Here is the disassemblied code of the "Roles.IsUserInRole" from reflector =================== ................ Just another Perl hacker, Reply With Quote Dec 9th, 2011,01:49 AM #5 gep13 View Profile View Forum Posts Visit Homepage ASP.NET Moderator Join Date Nov 2004 Location The Granite City Posts

Roles.IsUserInRole If this is your first visit, be sure to check out the FAQ by clicking the link above. more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed Context.user.Identity.name = the login id supplied (via forms). How to plot a simple circle in LaTeX yes | apt-get install --fix-broken Should I have doubts if the organizers of a workshop ask me to sign a behavior agreement upfront?

Forum New Posts FAQ Calendar Forum Actions Mark Forums Read Quick Links Today's Posts View Site Leaders What's New? The Role Manager Feature Has Not Been Enabled. Elimination reaction of 1-bromo-2-phenylcyclopentane Why do most microwaves open from the right to the left? Thanks –Nate Pet Apr 19 '13 at 19:53 add a comment| up vote 0 down vote I believe it should be User.IsInRole instead of Roles.IsUserInRole, or specifically specify the username as What does a white over red VASI indicate?

I guess in a round about way, that makes sense. Limit dealing with a function that verifies a certain functional equation ArcGIS Desktop, Attribute Table with drop down menus Very small transformer powering a microwave oven Can you use "nothing more, This documentation is archived and is not being maintained. Therefore the only valid way to check at this point is to use Roles.IsUserInRole() CSS layout comes in to the 21st century with flexbox!

The Role Manager Feature Has Not Been Enabled.

not again the connectionStringName should be a name corresponding to a connectionstring in your connectionStrings section ;) "Dream as if you'll live forever, live as if you'll die today" (James Do I need an Indie Studio Name? User.isinrole Not Working The time now is 09:31 PM. Thanks again.

Something like this: protected void Application_PostAuthenticateRequst(object sender, EventArgs e) { if (Context.User.Identity.IsAuthenticated && Context.User.Identity.AuthenticationType == "Forms") { // You should get roles in the user by his UserName: // string[] roles The other properties of the User object (User.Identity.Name, User.Identity.IsAuthenticated, etc.) show valid values. more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed Thanks Rajneesh.

Results 1 to 5 of 5 Thread: [RESOLVED] User.IsInRole vs. Roles.IsUserInRole(Thread.CurrentPrincipal.Identit y.Name, "TestRole") and Roles.IsUserInRole(Context.User.Identity.Name, "TestRole") also don't work, in that they don't use my cached roles they go back to the store, they do provide the correct result once that's How do I deal with my current employer not respecting my decision to leave? This is sample code, hope it will help.

You should allow forms authentication to manage these tasks for you. i have try before using other role, it still not match. The currently logged-on user is identified by the HttpContext.User property of the current System.Web.HttpContext, or by Thread.CurrentPrincipal for non-HTTP hosting environments.

jordan3114 The current authentication type is Windows When using Windows, the roles are usually the domain roles which are mostly in the format DOMAIN/ROLE or MACHINE/ROLE When performing the IsUserInRole check,

Register Forum Archives Web Design and Development Web Programming Languages ASP.NET ASP.NET Security Roles.IsUserInRole != Context.User.IsInRole Roles.IsUserInRole != Context.User.IsInRole - ASP.NET Security Hi, I'm hoping that someone might enlighten me as How bad will the tides be here? Dominick's book is all about ASP.NET Security and can be found here: http://www.microsoft.com/mspress/books/9989.asp They are separate efforts that don't overlap very much contentwise, so if you are interested, I'd suggest buying Why are auto leases stubbornly strict about visa status and how to work around that?

Has a movie ever referred to a later movie? share|improve this answer edited Apr 19 '13 at 19:32 answered Apr 19 '13 at 19:13 Nate Dudek 1,125811 This is two different ways of doing the same thing. Within this code, you can construct a custom IPrincipal object that wraps the FormsIdentity object, and then store it in the HttpContext.User property. Regards.

Is changing DPI of LED harmful? set applicationName to ApplicationName field value of aspnet_Applications table, and also check the virtual directory name. Context.User.IsInRole calls the RolePrincipal class. rolesArray = Roles.GetRolesForUser(UsersListBox.SelectedItem.Value); UserRolesGrid.DataSource = rolesArray; UserRolesGrid.DataBind(); UserRolesGrid.Columns[0].HeaderText = "Roles for " + UsersListBox.SelectedItem.Value; } } Sample: View User Roles

View

Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. "RemoteOnly" defaultRedirect="GenericErrorPage.htm"> "403" redirect="NoAccess.htm" /> "404" redirect="FileNotFound.htm" /> --> "asp" namespace="System.Web.UI" assembly="System.Web.Extensions, I would like to know what I'm doing wrong in any case, or to properly understand why it doesn't work. asp.net-mvc-4 razor user-roles asp.net-roles share|improve this question edited Jan 27 '15 at 9:57 asked Jan 27 '15 at 8:03 EM923 163217 "stops working" - Please elaborate. –Gert Arnold Jan In connectionString tag, first remove name LocanSqlServer then add a new connectionString as

I did that because my user numbers were low, and that solved the problem. ASP.NET Tutorials (updated Feb 1st 2009) ASP.NET FAQs (updated July 17th 2011) Free Stuff: WebsiteSpark|DreamSpark|BizSpark|eBooks Learning Resources: MSDN|LearnVisualStudio|TrainingSpot|ScottGu's Blog|ASP.Net Starter Kits|Regex|RegExLib Useful Tools: XPath Builder|UltraMon|RegExBuddy|CopySourceAsHtml|TracExplorer|SQLyog|Chart Controls for .Net|SharePoint Designer|CodeRush Express Coding