Bug #44414 MySQLRoleProvider says no roles when there clearly are.
Submitted: 23 Apr 2009 1:37 Modified: 26 May 2009 13:13
Reporter: Jimmy Lee Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.0.3 OS:Windows
Assigned to: Reggie Burnett CPU Architecture:Any
Tags: Connector/Net, roleprovider, roles

[23 Apr 2009 1:37] Jimmy Lee
Description:
The MySQLRoleProvider reports that there are no roles when there are. Was working in 6.0.0

How to repeat:
Using ASP.NET Website Configurator for example, the security section will show no roles.

You can successfully add roles, however, it will still report 0 roles.

If you try to add the same role again, it complains, because it exists in the DB.
[23 Apr 2009 7:28] Tonci Grgin
Hi Jimmy and thanks for your report.

I'm using c/NET 6.0.2, .NET FW 3.5 and VS2008Pro on W2K8SEx64 box:
  http://localhost:64134/asp.netwebadminfiles/security/security.aspx
  Roles
    Existing roles: 0
    Disable Roles
    Create or Manage roles
Create or manage roles -> add 2 roles -> go back to security.aspx:
  Roles
    Existing roles: 2
    Disable Roles
    Create or Manage roles

I guess I can't repeat your problem or am I missing something?
[24 Apr 2009 0:53] Jimmy Lee
Hmm,

Maybe our web.config isn't right somehow?

Could you point me to any documentation on this? Right now I'm going off some blog and I don't know how 'official' that is :)

Is the only way to enable roles and membership via manually configuring web.config?
[24 Apr 2009 1:10] Jimmy Lee
Here's my web.config xml

 <roleManager enabled="true" defaultProvider="MySQLRoleProvider">
      <providers>
        <clear />
        <add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.0.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" autogenerateschema="true" connectionStringName="EmoHelpMySQL" applicationName="/" />
      </providers>
    </roleManager>
    <membership defaultProvider="MySQLMembershipAppProvider">
      <providers>
        <clear />
        <add name="MySQLMembershipAppProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.0.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" autogenerateschema="true" connectionStringName="EmoHelpMySQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" passwordFormat="hashed" maxInvalidPasswordAttempts="7" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" />
      </providers>
    </membership>
[24 Apr 2009 4:49] Jimmy Lee
More info. Sorry for the bits and pieces.

We've tried on Vista 32 bit and Vista 64 bit VS2008.

When we uninstall and go back to 6.0.0, the roles are working again.
[24 Apr 2009 6:03] Tonci Grgin
Jimmy, thanks for info provided.
[24 Apr 2009 6:59] Jimmy Lee
Tested on 6.0.3, we had the same issue too.
[24 Apr 2009 8:29] Tonci Grgin
Jimmy, can you please attach sample project demonstrating this problem?
[26 Apr 2009 23:52] Jimmy Lee
sample project

Attachment: WebSite1.zip (application/x-zip-compressed, text), 8.16 KiB.

[27 Apr 2009 7:36] Tonci Grgin
Bug#44459 was marked as duplicate of this report.
[27 Apr 2009 8:12] Tonci Grgin
Jimmy, I have problem with your test case:
  The following message may help in diagnosing the problem: Unable to initialize provider. Missing or incorrect schema. (F:\PublicShare\temp\Bug44414\web.config line 45)

I have executed your script and added users as described. I have also changed "TestMySQL" to match my environment. Both "admin" and "basic" users work as expected.

Any ideas?
[27 Apr 2009 8:27] Jimmy Lee
don't see anything wrong with my web.config?

line 45 points to <add name="MySQLMembershipAppProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.0.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" autogenerateschema="true" connectionStringName="TestMySQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" passwordFormat="hashed" maxInvalidPasswordAttempts="7" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" />

Membership works for us too, just not roles...
[27 Apr 2009 8:31] Jimmy Lee
could you, Tonci, perhaps create a sample project that I could try? :)
[3 May 2009 10:47] Nalle Jacobsson
This bug is also present in 5.2.6. Also, Roles.IsUserInRole() does not function correctly, it returns false when it should return true.

Downgrading to 5.2.5 fixes it.
[3 May 2009 20:45] Chris Pels
I have also reported this same bug in #44414.
[3 May 2009 20:46] Chris Pels
Make that #44419.
[3 May 2009 21:28] Chris Pels
You say downgrading to 5.2.5 works, but the current 5.2 d/l is 5.2.6. Any idea on how to get 5.2.5 for the interim until this is fixed?
[3 May 2009 22:48] Nalle Jacobsson
Get 5.2.5 here:

http://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-5.2.5.zip/from/pick
[4 May 2009 8:34] Tonci Grgin
Bug#44619 was marked as duplicate of this report.
[5 May 2009 9:57] Tonci Grgin
Bug#44655 was marked as duplicate of this report.
[6 May 2009 20:42] S. Davis
MySQL logs the following SQL query:
    SELECT r.name FROM my_aspnet_Roles r  WHERE r.applicationId=-1

Should GetRolesByUserName use app.FetchId(connection) instead of app.Id?
[6 May 2009 23:25] S. Davis
With respect to reproducing the bug:

The first time you add Roles using the ASP.NET Web Site Administration tool, they appear in the list, but if you restart the tool, they don't appear.
[6 May 2009 23:36] Chris Pels
Also, when you click the "manage" link there is an error and when you add/edit a user there are no roles listed for selection even though they are in the DB table.
[7 May 2009 8:49] Tonci Grgin
Verified as described.

How to repeat:
  - Create database "cnet", execute SQL scripts
  - Open attached web project or create new one
  - Add references to MySQL.Data and MySQL.Web
  - Website/ASP.NET Configuration
  - Add roles. All there. Try to manage roles, roles disappear
  - Check log, no DELETES, roles are still in table
	147 Init DB	cnet
	147 Query	SELECT id FROM my_aspnet_Applications WHERE name='/'
	147 Query	INSERT INTO my_aspnet_Applications VALUES (NULL, '/', 'MySQL Role provider')
	147 Query	INSERT INTO my_aspnet_Roles Values(NULL, 1, 'admin')
	147 Init DB	cnet
	147 Query	SELECT r.name FROM my_aspnet_Roles r  WHERE r.applicationId=1
	146 Quit	
  - Add new user, no roles available
  - Try to recreate same roles fails, of course
and so on...

I am also noticing lack of documentation regarding this of which docs team has been notified. Thus it's possible I got it all wrong...
[7 May 2009 8:51] Tonci Grgin
Roles disappear with following error:
The following message may help in diagnosing the problem: Object reference not set to an instance of an object. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_roles_managesinglerole_aspx.Page_Load() at System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[7 May 2009 16:05] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/73588
[7 May 2009 16:06] Reggie Burnett
fixed in 5.2.7 and 6.0.4+
[7 May 2009 22:55] Jimmy Lee
yay!
[8 May 2009 0:50] Chris Pels
Being new to MySql, how do I d/l the patch in the link? It seems to be just a description of what was corrected. Is 6.0.4 available?

Thanks
[8 May 2009 1:17] Jimmy Lee
I'm guessing they'll release it soon enough.

Also you could try the SVN, not sure if the changes are open to public yet tho.
[8 May 2009 6:26] Tonci Grgin
Chris, it's a diff file one should apply to current sources :)
Jimmy, of course it's open, you can see the patch, right? Now, as bug is in documenting state I guess it's already pushed into repository too.

One can download SVN client (I use TortoiseSVN) and set up repo from http://svn.mysql.com/svnpublic/connector-net. Latest version (in this case 6.0) is in Trunk.
[19 May 2009 1:09] Jimmy Lee
Wondering if 6.0.4 is going to be released soon?
[19 May 2009 16:45] Reggie Burnett
We are planning to get 6.0.4 out in the next 1-2 weeks but we should have some build snapshots available from the snapshot page in the next couple of days
[26 May 2009 13:13] Tony Bedford
An entry was added to both the 5.2.7 and 6.0.4 changelogs:

The Connector/NET MySQLRoleProvider reported that there were no roles, even when roles existed.
[29 May 2009 0:47] Robson Castilho
Hi everybody

I had the same problem discussed here (connector 5.2.6).

Where can I download connector 5.2.7 from?

Thanx
[9 Jun 2009 15:55] Tonci Grgin
Bug#45337 was marked as duplicate of this report.