locked
ASP.NET Membership and Role Providers for PostGreSQL on WHS RRS feed

  • General discussion

  • The photo album web application included in the HP Media server is implemented as a java application to a PostGre SQL database backend.  This database contains tables for user login information, groups and users in groups.  Not unlike, all be it simpler, the Microsoft SQL membership provider.  I wanted to create a ASP.NET application that used this "membership" information yet still could use the standard membership related controls such as Login, loginview, loginstatus, etc.

    To do this membership and role provides are needed that would work with the progress SQL database already present.  I did a little research and was able to develop these providers.  They were developed using Microsoft Visual Web Developer 2008 Express.  A zip file containing the all the solution files can be downloaded from: http://www.decisioncatalyst.com/whs.aspx

    To use the providers you will need to get the dotConnect for PostgreSQL 4.0 express from devart.  This is the free limited functionality version.  While the express version does not have all the functionality as the other version.  It has everything needed to connect to the database using ADO.net.  You can download this software from the devart site at: http://www.devart.com/dotconnect/postgresql/download.html

    Once you have downloaded this kit, install the "Minimal" configuration on the windows media server.  The minimal configuration only includes the required DLLs.  It does not install the documentation or samples.

    To set use these providers in your ASP.NET site include them solution and make the following changes to your web.config file

    1. Add the following connection string:
    <add name="PgSQLServices" connectionString="User Id=postgres;Host=dwmedia;Database=sj;Schema=public;"/>

    2. Add a machine key to system.web such as the following:
    <machineKey validationKey="5AC560B49C595B8623469889EB63D6A8E60E3CD709DE0AD7C65F31CFF133CAD4E9058800CCBF47F485A1B92E28A80308219537F944E2AFFCAC7BE612AA6024B8" decryptionKey="C5444FBEEC1FDC027DCA6C64E907CAB4C076D20DFEB250CE" validation="SHA1" decryption="AES"/>

    3. Add the membership and rolemanager keys:
    <membership defaultProvider="PostGreMembershipProvider">
      <
    providers>
         <
    add name="PostGreMembershipProvider" type="PostGreMembershipProvider.pgSQLMembershipProvider"   connectionStringName="PgSQLServices" enablePasswordReset="true" requiresQuestionAndAnswer="true" writeExceptionsToEventLog="false"/>
       </
    providers>
    </
    membership>
    <
    roleManager defaultProvider="PostGreRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
       <
    providers>
          <
    add name="PostGreRoleProvider" type="PostGreRoleProvider.pgSQLRoleProvider" connectionStringName="PgSQLServices" writeExceptionsToEventLog="false"/>
       </
    providers>
    </
    roleManager>

    4. Change the authentication to Forms by adding the following keys to system.web
    <authentication mode="Forms">
        <
    forms loginUrl="login.aspx" name=".ASPXFORMSAUTH"/>
    </
    authentication>
    Thursday, January 8, 2009 8:08 PM

All replies

  • Very cool, thanks for posting this.
    Tentacle Blog: http://www.tentaclesoftware.com/blog/
    WHS Disk Management: http://www.tentaclesoftware.com/WHSDiskManagement/
    Friday, January 9, 2009 9:04 PM
    Moderator
  • I reorganized my web site and discovered that the login function would no longer work with this membership provider.  After a little debugging I discovered that when calling the Logonuser windows function I was using the incorrect option.  I was using the LOGON32_LOGON_INTERACTIVE.  I should have been using the LOGON32_LOGON_NETWORK instead.  This can be found in the ValidateUser method of the PostGreMembershipClass.vb module.

    I have fixed this.  You can down load an updated version of the solution from http://www.decisioncatalyst.com/whs.aspx

    Dennis
    Saturday, January 17, 2009 4:08 PM