Working with Login, Roles and Profiles

I just spent a lot of time coming up to speed on Membership and how to hook it into SQL Server.  I wanted to capture some notes and links…

 

A good overview of the different pieces: http://aspalliance.com/articleViewer.aspx?aId=743&pId=-1

Information on how to configure membership so a help desk can reset/retrieve passwords: http://mishler.net/PermaLink,guid,ea65afc0-2970-46f1-9412-4b57bbd906f4.aspx

ScottGu’s blog about adding Login, Roles, and Profile to ASP.NET 2.0 in only 24 lines of code: http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx

By default, custom Profile fields are saved in the aspnet_Profile table in a property bag approach, with the names also having some metadata on them.  This doesn’t work well if you need to do queries against that data.  A better approach is to use the SQLTableProfileProvider available from the Microsoft Sandbox here:  http://www.asp.net/downloads/sandbox/table-profile-provider-samples/  Unfortunately the code has a lot of comments and possible “to do” items in it, but a lot people seem to be using it and it seems stable.  The downloaded code has SQLTableProfileProvider depending on SQLStoredProcedureProfileProvider, but those two functions can just be copied over (somebody got lazy and created a dependency).  Note that any table you create needs to have a

The tooling support in Visual Studio for Profiles only works for Web Sites, not Web Applications.  This means you can’t say Profile.MyField.  You can either create your own custom code for it or just call Profile.GetPropertyValue(“MyField”) and Profile.SetPropertyValue(“MyField”,”MyValue”)  http://msdn.microsoft.com/en-us/library/aa983476(VS.80).aspx (look under “Converting Profile Object Code”)

Detailed tutorial about Membership, Roles, and Profile: http://www.4guysfromrolla.com/articles/120705-1.aspx