|
|
I'm having trouble getting the password reset control to function properly using this provider. My problem is primarily with the public override string ResetPassword(string username, string answer) function. It seems whenever I get to the following point in the function:
public override string ResetPassword(string username, string answer)
{
...
...
MySqlCommand updateCmd = new MySqlCommand("UPDATE `" + tableName + "`" +
" SET Password = @Password, LastPasswordChangedDate = @LastPasswordChangedDat" +
" WHERE Username = @Username AND ApplicationName = @ApplicationName AND IsLockedOut = False", conn);
updateCmd.Parameters.Add("@Password", MySqlDbType.VarChar, 255).Value = EncodePassword(newPassword);
updateCmd.Parameters.Add("@LastPasswordChangedDate", MySqlDbType.DateTime).Value = DateTime.Now;
updateCmd.Parameters.Add("@Username", MySqlDbType.VarChar, 255).Value = username;
updateCmd.Parameters.Add("@ApplicationName", MySqlDbType.VarChar, 255).Value = pApplicationName;
rowsAffected = updateCmd.ExecuteNonQuery();
}
It throws an error with the following Description:
An exception occurred communicating with the data source.
Action: ResetPassword
Exception: MySql.Data.MySqlClient.MySqlException: There is already an open DataReader associated with this Connection which must be closed first.
at MySql.Data.MySqlClient.MySqlCommand.CheckState()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at Simple.Providers.MySql.Net.MysqlMembershipProvider.ResetPassword(String username, String answer) in c:\Documents and Settings\Jeffrey G. Allen\My Documents\Visual Studio 2008\WebSites\HmongHealth\App_Code\SimpleMySQlProviders\NET\MysqlMembershipProvider.cs:line 1166
I've tried closing the datareader prior to this point but that doesn't help either.
Any ideas?
|
|
|
|
|
All I can think of is to try andclose the connection (conn) and then opening it again before the instantiating the new command.
"I'm about as expert as a palsy victim performing brain surgery with a pipe wrench."
Check out my site at JacquesSnyman.co.za
** Remember: An article is only as good as the votes it gets **
|
|
|
|
|
Hi,
Thanks for your DLL!
I had it working at all with "F5 mode" inside visual studio.
If I create a virtual directory on IIS I can see users list, but if i try to create a new user I get an error: System.Security.SecurityException and something like "access to registry system not allowed"
In stack analysis I see reference to your directory C:\Documents and Settings\jacques (see below)
How can I solve?
Thanks
System.ThrowHelper.ThrowSecurityException(ExceptionResource resource) +48
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +2887817
System.Diagnostics.EventLog.GetLogRegKey(String currentMachineName, Boolean writable) +96
System.Diagnostics.EventLog.ModifyOverflowPolicy(OverflowAction action, Int32 retentionDays) +179
Simple.Providers.MySQL.MysqlMembershipProvider.WriteToEventLog(Exception e, String action) in C:\Documents and Settings\jacques\My Documents\Personal\Projects\Simple\Simple.Providers.MySQL\MysqlMembershipProvider.cs:1703
Simple.Providers.MySQL.MysqlMembershipProvider.GetUserNameByEmail(String email) in C:\Documents and Settings\jacques\My Documents\Personal\Projects\Simple\Simple.Providers.MySQL\MysqlMembershipProvider.cs:1051
Simple.Providers.MySQL.MysqlMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) in C:\Documents and Settings\jacques\My Documents\Personal\Projects\Simple\Simple.Providers.MySQL\MysqlMembershipProvider.cs:426
System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() +305
System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) +105
System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +453
System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) +149
System.Web.UI.WebControls.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) +17
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.default_aspx.ProcessRequest(HttpContext context) +29
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
|
|
|
|
|
|
I get the same error as 'fpajaro' stated in an earlier message.
Using passwordFormat = "Clear" works just fine
This error occurs befóre an actual connection is made to the database, so the error lies not in there.
Targeting framework 2.0, 3.0 or 3.5 makes no difference.
It has to be in the membership provider implementation.
Any help or suggestions on this are very welcome.
Otherwise nice coding and thanks for sharing it... ...
Michael Bakker, the Netherlands.
|
|
|
|
|
Hi Michael.
Encrypted or Hashed passwords has not been implemented in the providers.
"I'm about as expert as a palsy victim performing brain surgery with a pipe wrench."
Check out my site at JacquesSnyman.co.za
** Remember: An article is only as good as the votes it gets **
|
|
|
|
|
Unlike a WebApplication Project Implementation in my ASP.NET WEB SITE qdo set in the web.config the name of my application that does not appear on the code of ASP.NET master page qdo WEBSITE he does not show the result of MySqlSiteMap or data in any control Navigation
applicationName="{Your App Name}"
My Web.Config
<siteMap defaultProvider="siteMapProvider" enabled="true">
<providers>
<clear />
<add name="siteMapProvider"
type="Simple.Providers.MySQL.MysqlSiteMapProvider"
connectionStringName="SimpleProviderConnectionString"
applicationName="AulasOnlineNet"
description="MySQL site map provider"
securityTrimmingEnabled="false"/>
</providers>
</siteMap>
My Code Behind - Master.Page
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Home : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
LADEF
|
|
|
|
|
Dude!
I don't want to be nasty or anything, but I do not know what you want. You english is uncomprehendable.
Please learn english or get a good translator to translate for you.
"I'm about as expert as a palsy victim performing brain surgery with a pipe wrench."
Check out my site at JacquesSnyman.co.za
** Remember: An article is only as good as the votes it gets **
|
|
|
|
|
Thanks anyway, but now thought to reply.Don't remember to add a reference to MySqlSiteMapProvider in my application Asp.Net Web Site is now working thanks
Translated from Portuguese to English by Google
LADEF
|
|
|
|
|
J. Snyman you could you explain why when I use a control-type sitemappath in currentnode, I explain what's happening
well let me explain you better then
My SiteMapProvider comes from below as MySqlSiteMapProvider
<!-- INÖCIO CONFIGS MYSQLSITEMAPPROVIDER -->
<siteMap defaultProvider="siteMapProvider" enabled="true">
<providers>
<clear />
<add name="siteMapProvider"
type="Simple.Providers.MySQL.MysqlSiteMapProvider"
connectionStringName="SimpleProviderConnectionString"
applicationName="myapp"
description="MySQL site map provider"
securityTrimmingEnabled="true"/>
</providers>
</siteMap>
<!-- FIM CONFIGS MYSQL SITEMAPPROVIDER -->
When the url it in my database in the field url MySqlSiteMapProvider is like this
id, myapp, 'Atibaia-SP.', 'shops - Atibaia-SP.', 'shops.aspx?subsessao=books&cidade=atibaia&uf=sp', '', parentid
it shows SiteMapPath in control of my application correctly or
Home :shops : books : Atibaia-SP.
Now when the data comes from my database of mysqlsitemapprovider that way
id, myapp, 'São Paulo-SP.', 'shops - São Paulo-SP.', 'shops.aspx?subsessao=books&cidade=são paulo&uf=sp', '', parentid
or
id, myapp, 'Jundiaí-SP.', 'shops - Jundia-SP.', 'shops.aspx?subsessao=books&cidade=´jundiaí&uf=sp', '', parentid
it just shows me this result in the control mode of execution in SiteMapPath
Home : shops
if you can help me now because I need to thank the currentnode, finally on all nodes that the accented characters with spaces and mapped by MySqlSiteMapProvider appear with accents and spaces in control sitemappath
LADEF
|
|
|
|
|
I'm sorry, but I can't understand what you are saying. Please get a decent translator to translate what you are trying to sy to english.
"I'm about as expert as a palsy victim performing brain surgery with a pipe wrench."
Check out my site at JacquesSnyman.co.za
** Remember: An article is only as good as the votes it gets **
|
|
|
|
|
Hello J Snyman as can be seen in the web.config of my asp.net 2.0 application that I am doing in VisualStudio2005 I have a 2 providers SqlSiteMapProvider which is the standard for use with authentication and security based on MemberShipProvider and another to use only the MySqlSiteMapProvider who also uses Roles of the MemberShipProvider the standard SQLServer as can be seen below in web.config
<appSettings/>
<connectionStrings>
<add name="MembershipConnection" connectionString="Data Source=mydatasource;Initial Catalog=mydb;User ID=sa;Password=mypass" providerName="System.Data.SqlClient"/>
<add connectionString="server=mysqlserver;database=mybd;user id=myid;pwd=mypass" name="SimpleProviderConnectionString" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
<system.web>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="SqlProvider" type="System.Web.Security.SqlMemberShipProvider"
connectionStringName="MembershipConnection"/>
</providers>
</membership>
<!-- INÍCIO CONFIGS MYSQLSITEMAPPROVIDER -->
<siteMap defaultProvider="siteMapProvider" enabled="true">
<providers>
<clear />
<add name="siteMapProvider"
type="Simple.Providers.MySQL.MysqlSiteMapProvider"
connectionStringName="SimpleProviderConnectionString"
applicationName="myapp"
description="MySQL site map provider"
securityTrimmingEnabled="true"/>
</providers>
</siteMap>
<authentication mode="Forms">
</authentication>
What you need to know is how to properly configure so that the two providers one for each state are recognized and work properly in my webapplication Project and how to ensure that the roles created Membership in the SQL are recognized in MySqlSiteMapProvider too.
If you can help me now thank you
Translated from Portuguese to English by Google
LADEF
|
|
|
|
|
I have been using the Membership provider for some time. Now I have added som 400 users, and I find (confirmed on 3 different servers) that it takes 10 seconds or more from the time you press the "Login"-button until you are actually logged in. Same thing when you press "log out".
Has anyone got any ideas on how to improve speeed? Code-optimazation, database-optimization...
|
|
|
|
|
I would start by looking at the SQL queries that are used when a user logs in/out.
Another solution might be to migrate to the MySQL/Net Connector that has Membership providers built in.
"I'm about as expert as a palsy victim performing brain surgery with a pipe wrench."
** Remember: An article is only as good as the votes it gets **
|
|
|
|
|
Do you have any experience with MySQL/Net Connector? Last time I looked, it was in som beta-test-stadium?
|
|
|
|
|
Unfortunately not.
I have read on the MySql site that the connector is now in productions release and stable.
"I'm about as expert as a palsy victim performing brain surgery with a pipe wrench."
Check out my site at JacquesSnyman.co.za
** Remember: An article is only as good as the votes it gets **
|
|
|
|
|
OK thx. Meanwhile I fond a bug of my own, having nothing to do with your connector. So I'll stick with that for now.
|
|
|
|
|
When I set passwordFormat="Encrypted" under the membership tag of my web.config file, I am receiving the following error when I click on the security link of the ASP.NET Configuration tool:
Hashed or Encrypted passwords are not supported with auto-generated keys
The same happens when I set passwordFormat="Hashed"
Any help on this would be highly appreciated!
|
|
|
|
|
Dear Jacques, many thanks for your excellent post. I am a real newbie to asp, having spent 25 years in 4GLs, and I have spent the last 3 days trying to find out how to use MySQL database as a membership database, so I can use the CreateUserWizard in my aspx files. I have finally, with your help, get as far as the whole application running without errors in the web.config file, however now when I go to the createuserwizard page, I get the error below. I can't for the life of me work out where this is going wrong. I have reduced it to just the rolemanager and membership bit in the web.config, and have changed the cookiepath to ~/cookies. I have added <@ Import Namespace="Simple.Providers.MySQL" %> into my master page, and your dll into the bin directory of my application.
Where am I going wrong???? Any help would be greatly appreciated to stop me going completely bananas on this (should be simple) issue!
Kind Regards, Ross Holland
Stack Trace:
[InvalidOperationException: Failed to map the path '/'.]
System.Web.Configuration.ProcessHostConfigUtils.MapPathActual(String siteName, VirtualPath path) +223
System.Web.Configuration.ProcessHostMapPath.MapPathCaching(String siteID, VirtualPath path) +611
System.Web.Configuration.ProcessHostMapPath.GetPathConfigFilenameWorker(String siteID, VirtualPath path, String& directory, String& baseName) +14
System.Web.Configuration.ProcessHostMapPath.System.Web.Configuration.IConfigMapPath.GetPathConfigFilename(String siteID, String path, String& directory, String& baseName) +38
System.Web.Configuration.HostingPreferredMapPath.GetPathConfigFilename(String siteID, String path, String& directory, String& baseName) +77
System.Web.Configuration.WebConfigurationHost.GetStreamName(String configPath) +162
System.Configuration.Internal.DelegatingConfigHost.GetStreamName(String configPath) +10
System.Configuration.BaseConfigurationRecord.InitConfigFromFile() +265
[ConfigurationErrorsException: An error occurred loading a configuration file: Failed to map the path '/'.]
System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal) +111
System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors) +41
System.Configuration.Configuration..ctor(String locationSubPath, Type typeConfigHost, Object[] hostInitConfigurationParams) +413
System.Configuration.Internal.InternalConfigConfigurationFactory.System.Configuration.Internal.IInternalConfigConfigurationFactory.Create(Type typeConfigHost, Object[] hostInitConfigurationParams) +30
System.Web.Configuration.WebConfigurationHost.OpenConfiguration(WebLevel webLevel, ConfigurationFileMap fileMap, VirtualPath path, String site, String locationSubPath, String server, String userName, String password, IntPtr tokenHandle) +934
System.Web.Configuration.WebConfigurationManager.OpenWebConfigurationImpl(WebLevel webLevel, ConfigurationFileMap fileMap, String path, String site, String locationSubPath, String server, String userName, String password, IntPtr userToken) +71
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(String path) +23
Simple.Providers.MySQL.MysqlMembershipProvider.Initialize(String name, NameValueCollection config) +1429
System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType) +579
System.Web.Configuration.ProvidersHelper.InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType) +115
System.Web.Security.Membership.Initialize() +1593
System.Web.UI.WebControls.LoginUtil.GetProvider(String providerName) +33
System.Web.UI.WebControls.CreateUserWizard.get_QuestionAndAnswerRequired() +90
System.Web.UI.WebControls.CreateUserWizard.UpdateValidators() +1134
System.Web.UI.WebControls.CreateUserWizard.CreateChildControls() +32
System.Web.UI.Control.EnsureChildControls() +97
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
System.Web.UI.Control.InitRecursive(Control namingContainer) +345
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Control.InitRecursive(Control namingContainer) +196
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7915
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +223
System.Web.UI.Page.ProcessRequest() +85
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +20
System.Web.UI.Page.ProcessRequest(HttpContext context) +110
ASP.register_aspx.ProcessRequest(HttpContext context) +30
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +441
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +65
|
|
|
|
|
Hi Ross...
Could you please post your web.config file? I would like to get the complete picture before trying to decipher the error.
Regards
Jacques Snyman
"I'm about as expert as a palsy victim performing brain surgery with a pipe wrench."
Check out my site at JacquesSnyman.co.za
** Remember: An article is only as good as the votes it gets **
|
|
|
|
|
Dear Jacques, hope this helps, Cheers Ross
<configuration>
<connectionStrings>
<add name="MyDB" connectionString="driver={MySQL ODBC 3.51 Driver};database=userid;option=16387;pwd=password;port=0;server=server-ip;uid=userid"
providerName="System.Data.Odbc" />
</connectionStrings>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" />
<authentication mode="Forms">
<forms loginUrl="login.aspx" />
</authentication>
<roleManager defaultProvider="roleProvider" enabled="true"
cacheRolesInCookie="false" cookieName=".ASPROLES"
cookieTimeout="7200" cookiePath="~/cookies" cookieRequireSSL="false"
cookieSlidingExpiration="true" cookieProtection="All">
<providers>
<clear />
<add name="roleProvider"
type="Simple.Providers.MySQL.MysqlRoleProvider"
connectionStringName="MyDB"
applicationName="myapp.org.uk"
description="MySQL role provider"/>
</providers>
</roleManager>
<membership defaultProvider="membershipProvider"
userIsOnlineTimeWindow="15">
<providers>
<clear />
<add name="membershipProvider"
type="Simple.Providers.MySQL.MysqlMembershipProvider"
connectionStringName="MyDB"
applicationName="myapp.org.uk"
enablePasswordRetrieval="true"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="true" passwordFormat="Encrypted"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
description="MySQL membership provider"/>
</providers>
</membership>
</system.web>
<location path="MembersOnly">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
</configuration>
|
|
|
|
|
The only issue I can see is that the tilde (~) might not be parsed by the server because it is in the config file. Have you tried to use a relative path (eg "/cookies/")?
Does the cookies directory exist?
"I'm about as expert as a palsy victim performing brain surgery with a pipe wrench."
Check out my site at JacquesSnyman.co.za
** Remember: An article is only as good as the votes it gets **
|
|
|
|
|
Hello J Snyman,
Compliments for the article is very interesting
I use Visual Studio 2008 c#, mysql 5 and ADO.NET Driver for MySQL (Connector/NET)
I am trying to work your suite, but I have difficulties.
In Web Site Administration Tool
-------------------------------------------------------------------
An exception occurred communicating with the data source.
Action: GetAllUsers
Exception: System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][Driver Manager ODBC] Nome origine dati non trovato e driver predefinito non specificato.
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.Odbc.OdbcConnection.Open()
at Simple.Providers.MySQL.MysqlMembershipProvider.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords)
Per ulteriori informazioni, consultare la Guida in linea e supporto tecnico
-------------------------------------------------------------------
In login.aspx
-------------------------------------------------------------------
System.InvalidOperationException non è stata gestita dal codice utente
Message="The ConnectionString property has not been initialized."
Source="System.Data"
StackTrace:
at System.Data.Odbc.OdbcConnection.PermissionDemand()
at System.Data.Odbc.OdbcConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.Odbc.OdbcConnection.Open()
at Simple.Providers.MySQL.MysqlMembershipProvider.ValidateUser(String username, String password)
at _Default.Login1_Authenticate(Object sender, AuthenticateEventArgs e) in c:\Inetpub\wwwroot\sito\Default.aspx.cs:line 34
at System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e)
at System.Web.UI.WebControls.Login.AttemptLogin()
at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
-------------------------------------------------------------------
Thanks
|
|
|
|
|
The example above uses the MySQL ODBC driver, not the .NET driver.
|
|
|
|
|