|
Tries to put the MySqlRoleProvider.cs and MySqlRoleProvider.cs in the App_Code ASP.NET folder of the your project. Moreover, put the MySql.Data.dll in the Bin ASP.NET folder of the your project and remove all reference to this dll in the project. It would have to work.
|
|
|
|
|
Still Same Problem, also i need to include AjaxControlToolkit.dll into Bin Folder, will it cause any problem?
-- modified at 22:06 Tuesday 20th March, 2007
|
|
|
|
|
How can I do to set the session value = the logged username with this provider?
Thanks!
|
|
|
|
|
I created a MySQL Profile Provider for myself and posted it on this site. Here is a link article
I didn't create it from scratch I used a MSAccess sample as a template and modified it to work with MySql. It seems to work pretty well. Maybe some other people will try it and let me know if there are any major issues.
-- modified at 16:12 Wednesday 28th June, 2006
|
|
|
|
|
I put the wrong link in the previous post. Here is the correct Link Profile Provider
|
|
|
|
|
Its telling me that I cannot access the database, but I know my user name is right
This happens whenever the "throw e" statement happens
If anyone can help it would be greatly apretiated
|
|
|
|
|
the "throw e" statements were there to on purpose, to halt the execution and show you that something went wrong with the mysql connection.
Note :
New version of this article here[^]
This is the last day I am replying to comments on this page.
|
|
|
|
|
Thanks for the great work! It helped me a lot.
What I was missing was an email validation and a check for the minimum password length.
What do you think about inserting these lines in method CreateUser?
if (password.Length < pMinRequiredPasswordLength)<br />
{<br />
status = MembershipCreateStatus.InvalidPassword;<br />
return null;<br />
}<br />
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +<br />
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +<br />
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";<br />
Regex re = new Regex(strRegex);<br />
if (!re.IsMatch(email))<br />
{<br />
status = MembershipCreateStatus.InvalidEmail;<br />
return null;<br />
}
-- Gunter Heiss.
|
|
|
|
|
I don't think that this is a good idea.
I think that it is not the provider's role to do checkings. Do your own checking with the asp.NET webforms validation controls.
Note :
New version of this article[^]
This is the last day I am replying to comments on this page.
|
|
|
|
|
Thank you. I was faced with the problem of having few MSSQl resources but a ast amount of mySQL resources. You article and code will help me make good use of the DBs that are available to me. This was a big help and greatly appreciated.
--Frank Jones
|
|
|
|
|
I realise this has been asked before, but is anyone aware of or working on a profile provider for .NET - MySql?
Have searched extensively on the internet and came up with the following-
Create my own (Document covers some of the areas of the creating a customised searching provider, but beyond my abilites)- http://www.theserverside.net/tt/articles/showarticle.tss?id=CreatingProfileProvider
Pay CoreLab a large amount for the priveledge (Not an option) - http://www.crlab.com/mysqlnet/[^]
Any help or direction would be greatly appreciated.
|
|
|
|
|
|
Have any idea how to use the server explorer in vs.net to manage mysql databases? Is there any way to show this up? Sorry for the offtopic
|
|
|
|
|
Im not expert, but from what I have seen there are currently two commonly used methods of connecting .NET to MySql:
Connector/net - Faster than the other but does not provide server explorer support.
Connector/ODBC - Slower but does provide server explorer support.
Either connectors can be found here:
http://www.mysql.com/products/connector/[^]
If you are looking to simply manage data, I would recommend SQLyog (Third party tool, but very good in my opinion.
Hope this helps.
|
|
|
|
|
First, thanks for that lovly code you have submitted. However I seem to have some problems. I'm wondering, is there some settings that has to be set if my mysql database is on a remote server? The error message longer down in the thread does not indicate that.
I have created the tables and I'm able to connect to this tables through normal code so to speak and use of the mysql driver.
Tips?
I also added the code to verify that things are setup correct.Testcode
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myConnection As MySqlConnection
Dim myDataAdapter As MySqlDataAdapter
Dim myDataSet As DataSet
Dim strSQL As String
Dim iRecordCount As Integer
myConnection = New MySqlConnection(ConfigurationManager.ConnectionStrings("ConnString").ConnectionString)
strSQL = "SELECT * FROM users;"
myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
myDataSet = New Dataset()
myDataAdapter.Fill(myDataSet, "mytable")
GridView1.DataSource = myDataSet
GridView1.DataBind()
End Sub
Action: GetUserNameByEmail
Exception: MySql.Data.MySqlClient.MySqlException: Table 'wno36258.Users' doesn't exist
at MySql.Data.MySqlClient.PacketReader.CheckForError()
at MySql.Data.MySqlClient.PacketReader.ReadHeader()
at MySql.Data.MySqlClient.PacketReader.OpenPacket()
at MySql.Data.MySqlClient.NativeDriver.ReadResult(Int64& affectedRows, Int64& lastInsertId)
at MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst)
at MySql.Data.MySqlClient.CommandResult..ctor(Driver d, Boolean isBinary)
at MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume)
at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar()
at Andri.Web.MySqlMembershipProvider.GetUserNameByEmail(String email)
Jone says:
There is no spone
|
|
|
|
|
strSQL = "SELECT * FROM wno36258.Users;"
If I added the wno36258.Users in the test code it got the same error. But why does it include the database name in front?
Jone says:
There is no spone
|
|
|
|
|
I had to create the database table with the database name before the table name. Did not think that was nesccary.
CREATE TABLE `wno36258`.`Users` (<br />
`PKID` VARCHAR( 36 ) NOT NULL ,<br />
`Username` VARCHAR( 255 ) NOT NULL ,<br />
`ApplicationName` VARCHAR( 100 ) NOT NULL ,<br />
`Email` VARCHAR( 100 ) NOT NULL ,<br />
`Comment` VARCHAR( 255 ) ,<br />
`Password` VARCHAR( 128 ) NOT NULL ,<br />
`PasswordQuestion` VARCHAR( 255 ) ,<br />
`PasswordAnswer` VARCHAR( 255 ) ,<br />
`IsApproved` TINYINT( 1 ) ,<br />
`LastActivityDate` DATETIME,<br />
`LastLoginDate` DATETIME,<br />
`LastPasswordChangedDate` DATETIME,<br />
`CreationDate` DATETIME,<br />
`IsOnLine` TINYINT( 1 ) ,<br />
`IsLockedOut` TINYINT( 1 ) ,<br />
`LastLockedOutDate` DATETIME,<br />
`FailedPasswordAttemptCount` INT( 11 ) ,<br />
`FailedPasswordAttemptWindowStart` DATETIME,<br />
`FailedPasswordAnswerAttemptCount` INT( 11 ) ,<br />
`FailedPasswordAnswerAttemptWindowStart` DATETIME,<br />
PRIMARY KEY ( `PKID` )
)
Jone says:
There is no spone
|
|
|
|
|
I am trying to get this running on my host's server (works fine on my desktop)... however, I am running into this problem...
Line 29:
|
|
|
|
|
Very impressed. Got this up and running in around half an hour with MYSQL version 5 and managed to deploy it to my ISP who are running 4.4.12 MYSQL
Works perfectly on both versions.
Do you have any plans to add in a profile provider class?
Thanks again.
-- modified at 8:37 Friday 12th May, 2006
|
|
|
|
|
I to am very impressed! I got the membership and role providers setup without any problems. Nice job!
I would love to see a profile provider class implemented as well. I did a fair amount of searching online and couldn't find any examples. The only thing I found was MySqlDirect from CoreLab, but that is a library that comes with a pretty high price tag. I am fine using the MySQL ADO.Net Data Provider, so I don't need the other functionality of the MySqlDirect solution. The only thing I would use this library for is the provider classes.
Thanks,
John
|
|
|
|
|
|
Thanks to Rakotomalala Andriniaina for all of his outstanding work on this.
Ive ran through all of the info here on the site and attempted to apply it to my ASP.Net 2.0 app (Using Visual Web Developer 2005 Express and MySql 5).
1. Found the SQL statements to have problems with MYSql 5.
I ended up creating the first two tables myself, but got the rest of the statements to execute okay. Using slightly modified code (Within SQLyog), listed below:
ALTER TABLE usersinroles
ADD INDEX ( Username, Rolename, ApplicationName) ;
ALTER TABLE roles
ADD INDEX ( Rolename , ApplicationName ) ;
CREATE TABLE users (
PKID varchar(36) NOT NULL default '',
Username varchar(255) NOT NULL default '',
ApplicationName varchar(100) NOT NULL default '',
Email varchar(100) NOT NULL default '',
Comment varchar(255) default NULL,
Password varchar(128) NOT NULL default '',
PasswordQuestion varchar(255) default NULL,
PasswordAnswer varchar(255) default NULL,
IsApproved tinyint(1) default NULL,
LastActivityDate datetime default NULL,
LastLoginDate datetime default NULL,
LastPasswordChangedDate datetime default NULL,
CreationDate datetime default NULL,
IsOnLine tinyint(1) default NULL,
IsLockedOut tinyint(1) default NULL,
LastLockedOutDate datetime default NULL,
FailedPasswordAttemptCount int(11) default NULL,
FailedPasswordAttemptWindowStart datetime default NULL,
FailedPasswordAnswerAttemptCount int(11) default NULL,
FailedPasswordAnswerAttemptWindowStart datetime default NULL,
PRIMARY KEY (PKID)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
2. Recompiled the two cs files using the following syntax for the two files:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>csc /r:C:\inetpub\wwwroot\bin\MySql.Data.dll /target:library /out:c:\Inetpub\wwwroot\bin\MySqlMembershipProvider.dll C:\Inetpub\wwwroot\App_Code\MySqlMembershipProvider.cs
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>csc /r:C:\inetpub\wwwroot\bin\MySql.Data.dll /target:library /out:c:\Inetpub\wwwroot\bin\MySqlRoleProvider.dll C:\Inetpub\wwwroot\App_Code\MySqlRoleProvider.cs
3. Put the two dlls into the app_code folder as previously stated, but also had to create a reference within my application (Using the Reference GUI in Visual Web Developer) to the two dlls. It just would not work otherwise.
4. Modified my web.config to be this:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appsettings>
<connectionstrings>
<add name="ConnString"
="" connectionstring="Database=db_serialnumering;Data Source=localhost;
User Id=YOURUSERNAME;Password=YOURPASS">
<system.web>
<compilation debug="true" strict="false" explicit="true">
<assemblies>
<add assembly="MySql.Data, Version=1.0.7.30072, Culture=neutral, PublicKeyToken=C5687FC88969C49E">
<pages>
<namespaces>
<clear>
<add namespace="System">
<add namespace="System.Collections">
<add namespace="System.Collections.Specialized">
<add namespace="System.Configuration">
<add namespace="System.Text">
<add namespace="System.Text.RegularExpressions">
<add namespace="System.Web">
<add namespace="System.Web.Caching">
<add namespace="System.Web.SessionState">
<add namespace="System.Web.Security">
<add namespace="System.Web.Profile">
<add namespace="System.Web.UI">
<add namespace="System.Web.UI.WebControls">
<add namespace="System.Web.UI.WebControls.WebParts">
<add namespace="System.Web.UI.HtmlControls">
<authentication mode="Windows">
<rolemanager defaultprovider="MySqlRoleProvider"
="" enabled="true" cacherolesincookie="true" cookiename=".ASPROLES" cookietimeout="30" cookiepath="/" cookierequiressl="false" cookieslidingexpiration="true" cookieprotection="All">
<providers>
<clear>
<add
name="MySqlRoleProvider"
="" type="Andri.Web.MySqlRoleProvider" connectionstringname="ConnString" applicationname="SerialNumbering" writeexceptionstoeventlog="true">
<membership defaultprovider="MySqlMembershipProvider"
="" userisonlinetimewindow="15">
<providers>
<clear>
<add
name="MySqlMembershipProvider"
="" type="Andri.Web.MySqlMembershipProvider" connectionstringname="ConnString" applicationname="SerialNumbering" enablepasswordretrieval="false" enablepasswordreset="true" requiresquestionandanswer="true" requiresuniqueemail="true" passwordformat="Hashed" writeexceptionstoeventlog="true">
5. I could then use the security tab.
Please refere to the previous To make these work on a VB website.... details.
These notes are simply what I had to do to make it work on a VB.net coded asp.net site.
Hope this helps.
|
|
|
|
|
Thanks for providing this code. It saves me having to work it out myself! I haven't tried out the actual code yet, but I did have some problems running the SQL script on MySQL 4.1 using phpMyAdmin and I thought I would share what I found out.
For anyone using MySQL 4.1 and having trouble, here are the changes I had to make:
- Replace single straight quotes with grave accents (`)
- Change the ApplicationName to a VARCHAR(255) in the CREATE TABLE `usersinroles` command (otherwise the corresponding ADD INDEX instruction fails)
I hope that helps!
|
|
|
|
|
Hi,
Thanks Andri for providing this! Works great once you get it configured.
I've successfully used the Login controls to allow new users to add themselves, but when I try to use the PasswordRecovery control, I keep getting the error: "Your answer could not be verified. Please try again." , even though I'm typing in the correct answer.
Could this have something to do with the encryption? I changed the encryption string to a different hex value in MySqlMembershipProvider.cs before I compiled it.
Any suggestions?
Thanks
Jay
|
|
|
|
|