User Role membership

I have a manually made login page.  So far I have been able to get the user to login just fine but it doesn't see the roles that that user is apart of.  Here's the twist, (at least for me):

 When I put a watch on  Roles.GetRolesForUser("user") it shows that the login name is part of the correct group. 

Yet if I put a watch on User.IsInRole("Users") it comes back false....  What gives????  I can't redirect based on membership until I figure this out!

Just some clarification:

User name is user

user group that i am checking for is Users

0
JIKassab
3/4/2009 3:11:19 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

15 Replies
471 Views

Similar Articles

[PageSpeed] 32
Get it on Google Play
Get it on Apple App Store

What provider you're using for your Roles? SQL Server provider?


Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
0
Naom
3/4/2009 3:41:08 AM

I am using Sql Express for the main database, and aspnetdb that is pulled into the app_data folder.  I'm also using the aspnetroleprovider.

If I open the database tables(aspnet_users, aspnet_roles) through the vs server explorer I can see the correct info just fine. So I don't understand why I can see the roles via Roles.GetRolesForUser("user") but User.IsInRole("Users") returns false 

0
JIKassab
3/4/2009 12:58:39 PM

Look at your roles. you are first calling "user"

then You are looking for "Users"


Ryan Felton
Cape Town, South Africa



Great programmers are not born. They are compiled
0
ryafel
3/4/2009 1:19:16 PM

Look. you have GetRolesForUser("user") & User.IsInRole("Users")

GetRolesForUser("user") is fine. Then should User.IsInRole("Users") not be changed to User.IsInRole("user")?


Ryan Felton
Cape Town, South Africa



Great programmers are not born. They are compiled
0
ryafel
3/4/2009 1:22:32 PM

my user name that I am logging in is user.  the group I am checking for is Users.  Yeah, that is a bit confusing, I can see.  So when I check what roles the user is in with  Roles.GetRolesForUser("user") I can see the Users groups in the watch window, but when I use the User.IsInRole("Users") it returns false.

0
JIKassab
3/4/2009 1:25:26 PM

if (User.Identity.IsAuthenticated && (User.IsInRole("Clinic")))

This is what I have as validation for my registration page


Ryan Felton
Cape Town, South Africa



Great programmers are not born. They are compiled
0
ryafel
3/4/2009 1:38:33 PM

That would work great if User.IsInRole would return true.  That's my original problem, User.IsInRole returns false, even though the user is in the role and I can see that role when I use Roles.GetRolesforUser

0
JIKassab
3/4/2009 1:52:13 PM

If you are useing Visual Studio, Go to ASP.Net Configuration tool and check the user roles there. Just to make sure


Ryan Felton
Cape Town, South Africa



Great programmers are not born. They are compiled
0
ryafel
3/4/2009 2:18:17 PM

Yup, I can see the users, see the roles, and the User is assigned to the role.

0
JIKassab
3/4/2009 3:09:46 PM

Then i'm out. It works for me. is the user Activated?


Ryan Felton
Cape Town, South Africa



Great programmers are not born. They are compiled
0
ryafel
3/4/2009 3:23:54 PM

I used SQLProvider instead in our website. You can find it on the web.


Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
0
Naom
3/4/2009 4:29:22 PM

Can you elaborate?  Is SQLProvider a third party provider?  Do you have a link.  I google SQLProvider, and of course, a million different things comes up.  Thanks for the help!

0
JIKassab
3/4/2009 5:27:11 PM

Check http://peterkellner.net/2006/03/13/adding-personalization-via-profiles-to-the-objectdatasource-in-aspnet-20/


Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
0
Naom
3/4/2009 6:19:14 PM

Additional links that helped me before

You may start with http://msdn2.microsoft.com/en-us/magazine/cc163457.aspx and go through all links in this article.
>
>Check also
>http://flimflan.com/blog/CommentView.aspx?guid=679DB00A-AABE-4E78-A167-5C508685805E

See also http://weblogs.asp.net/scottgu/archive/2006/04/13/442772.aspx for the source code of the providers.


Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
0
Naom
3/4/2009 6:24:52 PM
Awesome!!  Thanks so much for the help!  I ended up using 

Roles.IsUserInRole("user", "Users")

0
JIKassab
3/4/2009 11:36:01 PM
Reply:

Similar Artilces:

Web Crawlers Web.config and .Net Roles/Membership
 I have a subfolder in my asp.net 3.5 application that contains a Web.config file that only allows certain roles to access one of the pages. My question is whether or not web crawlers can index that page's content.http://www.geneangelo.com web crawlers crawl only on publicly accessible sites (as anonymous user)Patrick OliverosWeb Developer - Emerson Electric Asia, Ltd. - ROHQwebthinker.wordpress.com  Great, thanks a lot.http://www.geneangelo.com...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Web Form and Web User Control
Hello, I have a Web User Control (ascx) that includes a button. This button has an onclick event method. This Web User control is included into a Web Form. (thru LoadControl). However, when I click on the button, the event method is not executed. What should I include in order it works fine? Thanks in advance. GAA. Using Loadcontrol is using dynamic controls and when using dynamic controls you must recreate the same dynamic controls ono postback to econstruct the page control tree. It is best if you do this during the Page PreInit event. How complex are your controls ...

How do I copy Users, Roles, Membership and so on from one web server to another?
Hello,I'm developing an ASP.NET 2.0 WebSite using VStudio2005 and SQLServerExpress 2005. I've created a lot of users and roles inside the aspnetdb.mdf database using the Membership and Roles classes.Now I'd like to deploy the website to the production server (where there is SQLServer2000) and I would like to copy the Users and Roles.My problem is:How do I copy Users, Roles, Membership (and so on) rows from my development computer to the production server?Is there a tool to import/export the entries?I do not think I can just bulk import all the rows of the tables using a sql script, since the...

Make all edit controls on web form read only except for 1 for certain user/role
 Hi.  I have a need to disable or make edit controls (textbox and dropdownlist) read only when role of the user is 'reviewer'.  If role is Review, he/she should only have access to the Reviewed checkbox and the buttons to save the change.  Anything else, he/she should not have access.  What is the best approach to this situation? Thank you.Rick.. Try this code..  private void getAllControls(ControlCollection ctls) { foreach (Control c in ctls) { if (c is System.Web.UI.WebControls.TextBox) { ...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

custom web user control and web form
Guys,          I am trying to develop a context menu control for all of my pages. what i am trying to do is that i want the control to pick a datasource from the markup and then check whether its an xml file or a datatable. I created a class called datasource.   /**************************DataSource Class****************************/  public class DataSource { /// <summary> /// This is to identify unique elements from the markup /// </summary>protected string _ID; /// <summary> /// This will be the Datasource ID e...

Web User Control Not rendering in Web Form
I have created a Web User control that is made up of a Multiview with 2 views inside the Multiview. I have buttons on both views and a gridview on 1 view. My question is when I drop this Web User Control on a Web Form all I see is [MultiView"MultiView1"] and when I view the from in the browser I dont see the Web User Control. I was wondering if someone could please tell me why the Web User Control is not displaying or rendering.     Thanks In Advance Hi, Please check your aspx file for correct reference, like following example: TestControl.ascx:<%@ Control ...

Solution for web forms that look just like paper forms ? User controls ? Adobe fillable forms ?
 I am looking at ways to web-enable a series of company forms that need to have the form itself look just like the paper version.  It would be great if I could use an image of the form itself as a background, and then draw the UI components on top of this.  Then there is the question of printing these forms complete with the data that was filled in.   What are some options for doing this kind of application ?  Im open to 3rd party solutions as well.  Our company currently has a desktop application which does this, but I want to come up with a web based solu...

Membership and Roles
Hi all, Is there a way to allow the user choose a role from a selection you provide them with? e.g. I have 3 types of users: admin, contractor, and landlord. Of course I don't want them to be able to assign themselves admin role, so how would I proceed? (I'm using C# by the way) This is what I have so far. Please note "Roles...();" is where I am stuck: -within my aspx page i have: <asp:WizardStep ID="CreateUserWizardStep2" runat="server" Title="Contractor or Landlord?"> <asp:ListBox ID="ListBox1" runat=&q...

Sending email to all users in Membership database / all users by role.
I am trying to send emails to ALL users in the membership database.  Right now i am using this VB code to send an email in a web form.   Can anyone help me with the code to send this message in the web form to everyone in my membership database? Or to all users in the database assigned to a specific ROLE? (Actually that would be better).   Protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendEmail.Click Const ToAddress As String = "xxxj@xxxx.com,xxxx@xxxx.com,xxx@xxx.com" Dim mm As New MailMessage(UsersEmail.Text, ToAddress) ...

Access SqlDataSource on Web Form from a Web User Control...
Hello, I want to access a SqlDataSource on a Web Form fromout. a Web User Control. To do this, I have in my code behind of the Web User Control the folowing code: DropDownList1.DataSource = (this.Page.FindControl("SqlDataSource3") as SqlDataSource);DropDownList1.DataTextField = "Name;DropDownList1.DataValueField = "NameIDropDownList1.DataBind(); But, the control (ic. SqlDataSource3) is not found. Even other controls like labels and buttons are not found with the FindControl. What am I doing wrong? Thanks Andromedaris     This is not much of a surprise,...

validate Textbox in Web User Control from web form?
ASP.NET 2.0 I have a web user control that contains a textbox.  I need to add some validation (like requiredfieldvalidator, comparevalidator, etc). I would normally add the validator to my web user control by placing the validator next to my textbox.  However, I need the validation message somewhere else on my web form, not near the user control. So how would I associate a validation control on my web form with the text box inside my web user control?  Can this be done; any alternatives out there? Thanks!   The error message should occur wherever you place the vali...

Pass data from Web User Control to Web Form
I have a Web Form that contains a Web User Control. The WUC displays dynamic content. I want to change the TITLE property of the Web Form, based on the contents of the WUC. For example, if the WUC displays information about Horses, I want to change the page title to "HORSES" by passing the string to the parent Web Form. I have tried playing with parameters and such, but I can't remember how I did this in the past. PLEASE HELP!~o0 Spin-Monkey Oo~ The best way to do this is by creating a public property on your web user control and accessing that from your web form. Check ...

Access a Web User Control Method from a Web Form
I'm trying to pass the Selected Index value from a web user control in a web form to the user controls selectedIndexchanged Sub.  I can't seem to figure out how to pass the information that I need to the user control and have it execute the sub routine. In the SelectedInedxChanged Sub I have a switch Statement and I want to get the index value from the web form where the user control is located and compare it to each case and then to have it execute the code for the case that it matches. What do I need to do? Hi, I am not sure if I understood your question correctly. I su...

Web resources about - User Role membership - asp.net.web-forms

Polish European Union membership referendum, 2003 - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Drivers of Facebook Shuttle Buses Eye Teamsters Membership
Facebook and several other tech companies in Silicon Valley provide shuttle buses to transport their employees, and according to The New York ...

NJ Membership (@NJMembership) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Membership Has Its Privileges
Right now, crossing one of the magical rep borders happens more or less unnoticed. People just gain the particular powers. Now, of course they ...

Membership Cards - a set on Flickr
... home Sign Up Explore Recent Photos The Commons Getty Collection Galleries World Map App Garden Camera Finder Flickr Blog Upload Sign In Membership ...

Calgary Public Library: New Look. New Library. Free Membership. - YouTube
CREATING THE WORLD’S BEST PUBLIC LIBRARY: NEW LOOK. NEW LIBRARY. FREE MEMBERSHIP. For Immediate Release: In a bold move to become the world’s ...

The benefits of private club membership in the UAE
Lifestyle membership clubs can offer cardholders exclusive leisure discounts across the Emirates. But there can be a big catch - you need to ...

New Brisbane Broncos CEO Paul White Flags Membership Drive
The coal executive taking over at the helm of the Brisbane Broncos has his eyes set on the thousands of fans who regularly turn up to home games ...

Joe Tripodi's ALP membership suspended
NSW ALP has suspended membership of Joe Tripodi amid a corruption inquiry.

Invite-only memberships expand at Canberra's sky-high lounge
... club &ndash; if they have been lucky enough to get an invite The 15th floor lounge billed as Canberra's most exclusive has quadrupled its membership ...

Resources last updated: 12/9/2015 5:42:58 PM