Custom Providers


The type attribute names the class you want to use to implement MembershipProvider. In Listing 5-6 above, it's set to the SqlMembershipProvider, but it could easily be set to a class that you write. For example, if you wanted to replace the account lockout feature of SqlMembershipProvider with a login delay, you could do that by starting with the source code for SqlMembershipProvider, modifying it however you like, and giving it a new name. (Although for this particular feature, you'll probably spend most of your time changing the stored procedures in the membership database.) You might be surprised to learn that the source code for all of the Microsoft providers for ASP.NET 2.0 are available to you royalty free,[12] and you are allowed to create derivative works under that license.

[12] If you'd like to download the source code, see http://msdn.microsoft.com/asp.net/downloads/providers/ or search for "ASP.NET Provider Toolkit."

Here's another helpful tip if you're planning on replacing the SQL provider or just learning more about how it works. You can ask aspnet_regsql to give you a dump of the SQL required to construct the provider tables, views, stored procedures, and so on. Here's the command (replace file.sql with the name of the output file that you want aspnet_regsql to create for you):

aspnet_regsql -A all -sqlexportonly file.sql 


This creates a text file with all table, view, and stored procedure definitions, and you can search it to find out how things work under the covers. This is invaluable for the SqlMembershipProvider, as much of the actual functionality is provided by these stored procedures.




Essential ASP. NET 2.0
Essential ASP.NET 2.0
ISBN: 0321237706
EAN: 2147483647
Year: 2006
Pages: 104

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net