Comments
litl_phil wrote: While it's nice that Google and Acer share the vision of cloud-based computing, it's also worth noting that we at litl already have a webbook on the market (available at litl.com) that runs our own cloud-based OS. Unlike Chrome, litlOS is focused on creating a new and better web experience for the home, so we don't have the usual browser interface, we have our own innovative UI. In conjunction with easel mode (litl's inverted-V position) and our growing cohort of litl channels (special apps t...
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Jon Box's .NET Blog: ASP.NET Membership Provider and Different Servers
I'm working on an application where I built a custom membership provider because of custom database scheme requirement

ASP.NET Membership Provider and Different Servers

I'm working on an application where I built a custom membership provider because of custom database scheme requirement.  My custom membership provider is using the hashed format for passwords and user answers.  I've got that working and now want to deploy the new application including the new provider.  Due to the encryption in ASP.NET being based on the MachineKey and wanting to share the data in development and early testing (ie. different web servers), I needed a MachineKey at the application level.

Thanks to an article in the patterns & practices ASP.NET 2.0 Security How To's, I found a snippet that would generate the keys for me.  I converted it to a Windows app so that I could just copy/paste the key into the Web.Config file in my development project.  While doing that, I discovered a small buy in the array declaration in thier sample.  It is corrected below.  To use the code, make a VB.NET WinForm project, add a multiline textbox and a button, paste this code in, and run.  I have made the code generate SHA1 for validation and AES for the decryption key.  Now I can run against the database from my development machine or the clients development server.  I can even copy the DB directly to my box for debugging purposes.

Imports System
Imports System.Text
Imports System.Security
Imports System.Security.Cryptography

Public Class Form1
    'from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000007.asp
    'Generate Cryptographically Random Keys
    'To generate cryptographically random keys: 
    'Use the RNGCryptoServiceProvider class to generate a cryptographically strong random number. 
    'Choose an appropriate key size. The recommended key lengths are as follows: 
    ' For SHA1, set the validationKey to 64 bytes (128 hexadecimal characters). 
    ' For AES, set the decryptionKey to 32 bytes (64 hexadecimal characters). 
    ' For 3DES, set the decryptionKey to 24 bytes (48 hexadecimal characters).

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    CreateMachineKeyConfig()
End Sub

Private Sub CreateMachineKeyConfig()
   
Dim sb As StringBuilder = New StringBuilder()
    sb.AppendLine(
"<machineKey ")
   
sb.AppendLine(" validationKey = """ + GenRandomValues(128) + """")
    sb.AppendLine(
" decryptionKey = """ + GenRandomValues(64) + """")
    sb.AppendLine(
" validation = ""SHA1""")
    sb.AppendLine(
" decryption = ""AES""")
    sb.AppendLine(
" />")
   
Me.TextBox1.Text = sb.ToString()
End Sub

Private Function GenRandomValues(ByVal len As Integer) As String
    Dim buff((len / 2) - 1) As Byte 'JBox added the decrement b/c of VB array decl syntax
    Dim rng As New RNGCryptoServiceProvider()
    rng.GetBytes(buff)
    Dim sb As New StringBuilder(Len)
    Dim i As Integer
    For i = 0 To buff.Length - 1
        sb.Append(
String.Format("{0:X2}", buff(i)))
    Next i
    Return sb.ToString
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    CreateMachineKeyConfig()
End Sub

End Class



About Jon Box
Jon Box is an Architect Evangelist in Developer & Platform Evangelism with the Microsoft Corporation. He coauthored Building Solutions with the Microsoft .NET Compact Framework, published by Addison-Wesley, and blogs at http://blogs.msdn.com/jonbox/default.aspx.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Can you share the source code for your ASP.NET Membership Provider? I need to build a Membership Proivder for a custom application that has been built for Windows and I need to have the web (DNN 4.3.2) access the user database.

Thanks for any help.

I'm working on an application where I built a custom membership provider because of custom database scheme requirement. My custom membership provider is using the hashed format for passwords and user answers. I've got that working and now want to deploy the new application including the new provider. Due to the encryption in ASP.NET being based on the MachineKey and wanting to share the data in development and early testing (ie. different web servers), I needed a MachineKey at the application level.


Your Feedback
Brian Armstrong wrote: Can you share the source code for your ASP.NET Membership Provider? I need to build a Membership Proivder for a custom application that has been built for Windows and I need to have the web (DNN 4.3.2) access the user database. Thanks for any help.
Australia News Desk wrote: I'm working on an application where I built a custom membership provider because of custom database scheme requirement. My custom membership provider is using the hashed format for passwords and user answers. I've got that working and now want to deploy the new application including the new provider. Due to the encryption in ASP.NET being based on the MachineKey and wanting to share the data in development and early testing (ie. different web servers), I needed a MachineKey at the application level.
Enterprise Open Source Magazine Latest Stories . . .
Oracle seems to have divided the open source ranks over the MySQL delay it’s having closing its acquisition of Sun. Eben Moglin, the GPL’s most ardent defender and delineator, the lawyer who has worked hand in glove for years with the Free Software Foundation’s founder Richard Stallman...
Cloud computing is a game changer. The cloud is disrupting traditional software and hardware business models by disrupting how IT service gets delivered. Entrepreneurial opportunities abound as this classic disruptive technology begins to proliferate, so it is no surprise that SYS-CON'...
The irony is that Oracle has advanced MySQL, lost money in the process, and helped its competitors - all at the same time. When Oracle buys Sun and controls MySQL the gift (other than to Microsoft SQL Server) keeps on giving as the existential threat to RDBs is managed by Redwood Shore...
WSO2, the open source SOA company, today announced the launch of the WSO2 Cloud Platform. Available today, the new WSO2 Cloud Platform features a family of WSO2 Cloud Virtual Machines; WSO2 Cloud Connectors for enabling fast, secure cloud services; and the multi-tenant WSO2 Governance-...
Now, the open source Mozilla Thunderbird client software can be used with Open-Xchange collaboration software. The "Community OXtender for Thunderbird" software connector gives users full access to appointments and contacts stored in the Open-Xchange Server and enables them to use Thun...
Morph Labs, a leading provider of enterprise cloud computing technology, today announced an introductory trial of the Morph CloudServer, an open, standards-based server IT organizations can use to rapidly model and evaluate their cloud implementations. A miniature "Cloud Environment in...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE