Bug #59438 setting Membership.ApplicationName has no effect

Submitted: 12 Jan 2011 8:31 Modified: 14 Feb 2011 19:26
Reporter: sergei z Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.3.6 and possibly earlier OS:Windows (.NET/Mono package)
Assigned to: CPU Architecture:Any
Tags: membership, membershipprovider

[12 Jan 2011 8:31] sergei z
Description:
It appears that Membership is initialized at startup once and for all, and setting Membership.ApplicationName has no effect after that. I'm tracing this to the MySql.Web.General.Application.FetchId(MySqlConnection) method in MySql.Web.dll. It only sets Application.Id once if it's -1. Subsequent changes in Application.Name have no effect. 

This behavior differs from Microsoft's SqlMembershipProvider. My application is an "administrator" and I need this functionality. Please refer to http://msdn.microsoft.com/en-us/library/system.web.security.membership.applicationname.asp...

How to repeat:
Setting Membership.ApplicationName does not have an effect.

Suggested fix:
Either:
1. MySql.Web.General.Application.FetchId(MySqlConnection) method in MySql.Web.dll to be changed as:

public int FetchId(MySqlConnection connection) {
    MySqlCommand command = new MySqlCommand("SELECT id FROM my_aspnet_Applications WHERE name=@name", connection);
    command.Parameters.AddWithValue("@name", this.Name);
    object obj2 = command.ExecuteScalar();
    this.Id = (obj2 == null) ? -1 : Convert.ToInt32(obj2);
    return this.Id;
}

or (more efficient)
2.1 MySql.Web.General.Application.FetchId(MySqlConnection) method in MySql.Web.dll becomes:

public int FetchId(MySqlConnection connection) { return this.Id; }

2.2 public field Application.Name becomes:

private string name;
public string Name { 
get { return this.name; }
set {
    if(this.name != value) {
        this.name = value;
MySqlCommand command = new MySqlCommand("SELECT id FROM my_aspnet_Applications WHERE name=@name", connection);
        command.Parameters.AddWithValue("@name", value);
        object obj2 = command.ExecuteScalar();
        this.Id = (obj2 == null) ? -1 : Convert.ToInt32(obj2);
    }   
}
[14 Feb 2011 19:26] Reggie Burnett
Fixed in 6.0.8, 6.1.6, 6.2.5, 6.3.7+

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.052 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.