none
Access Membership provider in WinForms Application (minRequiredNonalphanumericCharacters not working) RRS feed

  • Question

  • Hi,

        I am using the MS Access membership providers in a WinForms application. Everything works fine except that I can enter any password without restriction for a new member. In my app.config file I have minRequiredNonalphanumericCharacters='1' & minRequiredPasswordLength='7' but both seem to be ignored.

    Any help appreciated.

    Thanks

    Paul.

    app.config:

    <?xml version="1.0"?>
    <configuration>
      <configSections>
      </configSections>

      <connectionStrings>

        <add name="My_Application.Properties.Settings.ASPNETDBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\ASPNetDB.mdb;Persist Security Info=True" providerName="System.Data.OleDb"/>

        <add name="My_Application.Properties.Settings.MyApplicationConnectionString" connectionString="Data Source=|DataDirectory|\MyApplication.sdf;Max Database Size=1024;" providerName="System.Data.SqlServerCe.3.5"/>

        <add name="My_Application.Properties.Settings.MyApplicationDeviceConnectionString" connectionString="Data Source=|DataDirectory|\MyApplicationDevice.sdf;Max Database Size=1024;" providerName="System.Data.SqlServerCe.3.5"/>

      </connectionStrings>
      <system.web>

        <membership defaultProvider="AccessMembershipProvider">
          <providers>
            <clear/>
            <add name="AccessMembershipProvider" type="Samples.AccessProviders.AccessMembershipProvider,
                 SampleAccessProviders"
                 connectionStringName="My_Application.Properties.Settings.ASPNETDBConnectionString"
                 enablePasswordRetrieval="true"
                 enablePasswordReset="true"
                 requiresUniqueEmail="false"
                 requiresQuestionAndAnswer="true"
                 minRequiredPasswordLength="7"
                 minRequiredNonalphanumericCharacters="1"
                 applicationName="MyApplication"
                 passwordFormat="Encrypted"/>
          </providers>
        </membership>

        <roleManager enabled="true" defaultProvider="AccessRoleProvider">
          <providers>
            <add name="AccessRoleProvider" type="Samples.AccessProviders.AccessRoleProvider,
                 SampleAccessProviders"
                 connectionStringName="My_Application.Properties.Settings.ASPNETDBConnectionString"
                 applicationName="MyApplication"/>
          </providers>
        </roleManager>

        <profile enabled="true" defaultProvider="AccessProfileProvider">
          <providers>
            <add name="AccessProfileProvider" type="Samples.AccessProviders.AccessProfileProvider,
                 SampleAccessProviders"
                 connectionStringName="My_Application.Properties.Settings.ASPNETDBConnectionString"
                 applicationName="MyApplication"
                 description="Stores and retrieves profile data from an $safeprojectname$ database."/>
          </providers>
          <properties>
            <add name="FriendlyName" type="string" allowAnonymous="true" serializeAs="String"/>
            <add name="Height" type="int" allowAnonymous="true" serializeAs="String"/>
            <add name="Weight" type="int" allowAnonymous="true" serializeAs="Xml"/>
          </properties>
        </profile>

        <machineKey validationKey="F969F4284EB139391CF77CE640955E9A00C4E1A71384AC4CD992515AFE2BB8492FF76173423FE4E08D4BE78A884C99BD86EF79A309626BB2D4B33F85DFF8E83D"
                 decryptionKey="71C0883004AEC782F643917F1975CACA32827ECDA42522ADA6F3AB8BC379231A"
                 validation="SHA1"
                 decryption="AES"/>

      </system.web>
    </configuration>


    Paul Wainwright
    Wednesday, January 25, 2012 3:02 PM

Answers

  • Hi,

        I am using the MS Access membership providers in a WinForms application. Everything works fine except that I can enter any password without restriction for a new member. In my app.config file I have minRequiredNonalphanumericCharacters='1' & minRequiredPasswordLength='7' but both seem to be ignored.

    Any help appreciated.

    Thanks

    Paul.

    app.config:

    <?xml version="1.0"?>
    <configuration>
      <configSections>
      </configSections>

      <connectionStrings>

        <add name="My_Application.Properties.Settings.ASPNETDBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\ASPNetDB.mdb;Persist Security Info=True" providerName="System.Data.OleDb"/>

        <add name="My_Application.Properties.Settings.MyApplicationConnectionString" connectionString="Data Source=|DataDirectory|\MyApplication.sdf;Max Database Size=1024;" providerName="System.Data.SqlServerCe.3.5"/>

        <add name="My_Application.Properties.Settings.MyApplicationDeviceConnectionString" connectionString="Data Source=|DataDirectory|\MyApplicationDevice.sdf;Max Database Size=1024;" providerName="System.Data.SqlServerCe.3.5"/>

      </connectionStrings>
      <system.web>

        <membership defaultProvider="AccessMembershipProvider">
          <providers>
            <clear/>
            <add name="AccessMembershipProvider" type="Samples.AccessProviders.AccessMembershipProvider,
                 SampleAccessProviders"
                 connectionStringName="My_Application.Properties.Settings.ASPNETDBConnectionString"
                 enablePasswordRetrieval="true"
                 enablePasswordReset="true"
                 requiresUniqueEmail="false"
                 requiresQuestionAndAnswer="true"
                 minRequiredPasswordLength="7"
                 minRequiredNonalphanumericCharacters="1"
                 applicationName="MyApplication"
                 passwordFormat="Encrypted"/>
          </providers>
        </membership>

        <roleManager enabled="true" defaultProvider="AccessRoleProvider">
          <providers>
            <add name="AccessRoleProvider" type="Samples.AccessProviders.AccessRoleProvider,
                 SampleAccessProviders"
                 connectionStringName="My_Application.Properties.Settings.ASPNETDBConnectionString"
                 applicationName="MyApplication"/>
          </providers>
        </roleManager>

        <profile enabled="true" defaultProvider="AccessProfileProvider">
          <providers>
            <add name="AccessProfileProvider" type="Samples.AccessProviders.AccessProfileProvider,
                 SampleAccessProviders"
                 connectionStringName="My_Application.Properties.Settings.ASPNETDBConnectionString"
                 applicationName="MyApplication"
                 description="Stores and retrieves profile data from an $safeprojectname$ database."/>
          </providers>
          <properties>
            <add name="FriendlyName" type="string" allowAnonymous="true" serializeAs="String"/>
            <add name="Height" type="int" allowAnonymous="true" serializeAs="String"/>
            <add name="Weight" type="int" allowAnonymous="true" serializeAs="Xml"/>
          </properties>
        </profile>

        <machineKey validationKey="F969F4284EB139391CF77CE640955E9A00C4E1A71384AC4CD992515AFE2BB8492FF76173423FE4E08D4BE78A884C99BD86EF79A309626BB2D4B33F85DFF8E83D"
                 decryptionKey="71C0883004AEC782F643917F1975CACA32827ECDA42522ADA6F3AB8BC379231A"
                 validation="SHA1"
                 decryption="AES"/>

      </system.web>
    </configuration>


    Paul Wainwright

    Could not find a fix so used this from regexlib.com

     

    Regex passwordRegex = new Regex(@"(?=^[!@#$%\^&*()_\-+=\[{\]};:<>|\./?a-zA-Z\d]{7,}$)(?=([!@#$%\^&*()_\-+=\[{\]};:<>|\./?a-zA-Z\d]*\W+){1,})[!@#$%\^&*()_\-+=\[{\]};:<>|\./?a-zA-Z\d]*$");

     

     


    Paul Wainwright
    • Marked as answer by pr_wainwright Friday, January 27, 2012 10:07 AM
    Friday, January 27, 2012 10:07 AM

All replies

  • Hi,

        I am using the MS Access membership providers in a WinForms application. Everything works fine except that I can enter any password without restriction for a new member. In my app.config file I have minRequiredNonalphanumericCharacters='1' & minRequiredPasswordLength='7' but both seem to be ignored.

    Any help appreciated.

    Thanks

    Paul.

    app.config:

    <?xml version="1.0"?>
    <configuration>
      <configSections>
      </configSections>

      <connectionStrings>

        <add name="My_Application.Properties.Settings.ASPNETDBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\ASPNetDB.mdb;Persist Security Info=True" providerName="System.Data.OleDb"/>

        <add name="My_Application.Properties.Settings.MyApplicationConnectionString" connectionString="Data Source=|DataDirectory|\MyApplication.sdf;Max Database Size=1024;" providerName="System.Data.SqlServerCe.3.5"/>

        <add name="My_Application.Properties.Settings.MyApplicationDeviceConnectionString" connectionString="Data Source=|DataDirectory|\MyApplicationDevice.sdf;Max Database Size=1024;" providerName="System.Data.SqlServerCe.3.5"/>

      </connectionStrings>
      <system.web>

        <membership defaultProvider="AccessMembershipProvider">
          <providers>
            <clear/>
            <add name="AccessMembershipProvider" type="Samples.AccessProviders.AccessMembershipProvider,
                 SampleAccessProviders"
                 connectionStringName="My_Application.Properties.Settings.ASPNETDBConnectionString"
                 enablePasswordRetrieval="true"
                 enablePasswordReset="true"
                 requiresUniqueEmail="false"
                 requiresQuestionAndAnswer="true"
                 minRequiredPasswordLength="7"
                 minRequiredNonalphanumericCharacters="1"
                 applicationName="MyApplication"
                 passwordFormat="Encrypted"/>
          </providers>
        </membership>

        <roleManager enabled="true" defaultProvider="AccessRoleProvider">
          <providers>
            <add name="AccessRoleProvider" type="Samples.AccessProviders.AccessRoleProvider,
                 SampleAccessProviders"
                 connectionStringName="My_Application.Properties.Settings.ASPNETDBConnectionString"
                 applicationName="MyApplication"/>
          </providers>
        </roleManager>

        <profile enabled="true" defaultProvider="AccessProfileProvider">
          <providers>
            <add name="AccessProfileProvider" type="Samples.AccessProviders.AccessProfileProvider,
                 SampleAccessProviders"
                 connectionStringName="My_Application.Properties.Settings.ASPNETDBConnectionString"
                 applicationName="MyApplication"
                 description="Stores and retrieves profile data from an $safeprojectname$ database."/>
          </providers>
          <properties>
            <add name="FriendlyName" type="string" allowAnonymous="true" serializeAs="String"/>
            <add name="Height" type="int" allowAnonymous="true" serializeAs="String"/>
            <add name="Weight" type="int" allowAnonymous="true" serializeAs="Xml"/>
          </properties>
        </profile>

        <machineKey validationKey="F969F4284EB139391CF77CE640955E9A00C4E1A71384AC4CD992515AFE2BB8492FF76173423FE4E08D4BE78A884C99BD86EF79A309626BB2D4B33F85DFF8E83D"
                 decryptionKey="71C0883004AEC782F643917F1975CACA32827ECDA42522ADA6F3AB8BC379231A"
                 validation="SHA1"
                 decryption="AES"/>

      </system.web>
    </configuration>


    Paul Wainwright

    Could not find a fix so used this from regexlib.com

     

    Regex passwordRegex = new Regex(@"(?=^[!@#$%\^&*()_\-+=\[{\]};:<>|\./?a-zA-Z\d]{7,}$)(?=([!@#$%\^&*()_\-+=\[{\]};:<>|\./?a-zA-Z\d]*\W+){1,})[!@#$%\^&*()_\-+=\[{\]};:<>|\./?a-zA-Z\d]*$");

     

     


    Paul Wainwright
    • Marked as answer by pr_wainwright Friday, January 27, 2012 10:07 AM
    Friday, January 27, 2012 10:07 AM
  • Hi Paul,

    Thanks for sharing your experience here, I think you can repost your question here: http://social.msdn.microsoft.com/Forums/en-US/accessdev/threads for better support.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 30, 2012 2:11 AM
    Moderator