Disallow duplicate email addresses in CreateUserWizard

Last post 05-14-2009 10:42 PM by info@learnbartending.com. 13 replies.

Sort Posts:

  • Disallow duplicate email addresses in CreateUserWizard

    03-22-2009, 10:29 AM
    • Member
      51 point Member
    • _Degan_
    • Member since 04-19-2008, 3:41 PM
    • Posts 38

    I am using CREATEUSERWIZARD which allows duplicate email addresses in membership.  However, for my purposes, I want to reject a duplicate email adress that already exists in the membership.

    I have seen this thread: http://forums.asp.net/p/1117970/1738068.aspx#1738068

    However the answer refers to a Web.Config section: <membership>
    <providers> that is not contained in my file.  Perhaps something has changed since this thread was answered, or perhaps I am missing something simple, as this seems like obvious functionality.

    In other respects, CREATEUSER WIZARD behaves correctly.

    Eric Speicher
  • Re: Disallow duplicate email addresses in CreateUserWizard

    03-22-2009, 4:09 PM
    • Star
      13,971 point Star
    • yasserzaid
    • Member since 09-22-2007, 9:10 PM
    • Egypt
    • Posts 2,597

    Hi

    try this in your web.config file just change connectionstring name with your's

    set requiresUniqueEmail="true"

    <membership defaultProvider="MyProvider" userIsOnlineTimeWindow="25">
       <providers>
        <add name="MyProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="eLocalize_ConnStr" applicationName="/" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
       </providers>
      </membership>
      <roleManager cacheRolesInCookie="true" cookieName="TaskCookie" cookiePath="/" cookieProtection="None" cookieRequireSSL="true" cookieSlidingExpiration="false " cookieTimeout="60"
                   defaultProvider="TaskRoleProvider" enabled="true">
       <providers>
        <add name="TaskRoleProvider" connectionStringName="eLocalize_ConnStr" applicationName="/" type="System.Web.Security.SqlRoleProvider"/>
       </providers>
      </roleManager>
      <!--SiteMap Provider-->
      <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
       <providers>
        <add name="XmlSiteMapProvider" description="Default SiteMap provider." type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap" securityTrimmingEnabled="true"/>
       </providers>
      </siteMap>

    Hope this helps

    Good Luck

  • Re: Disallow duplicate email addresses in CreateUserWizard

    03-22-2009, 4:46 PM
    Answer
    • All-Star
      61,685 point All-Star
    • anas
    • Member since 09-21-2006, 8:31 AM
    • Palestinian Territory, Occupied
    • Posts 6,930
    • Moderator

     Hi,

    You don't have to change the membersdhip settings.By default ,Membership provider doesn't allow duplicate emails.This is because "RequiresUniqueEmail" property is true by default.

    Are you using the SqlMembershipProvider ???

    Regards,

    Anas Ghanem | Blog

  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-04-2009, 8:56 AM
    • Member
      51 point Member
    • _Degan_
    • Member since 04-19-2008, 3:41 PM
    • Posts 38

    I added these sections to my web.config, editting teh connection string.  I get the following errors when attempting to use the membership provider:

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: Unrecognized configuration section membership.

    Source Error:

    Line 111:		</assemblyBinding>
    Line 112:	</runtime>
    Line 113:  <membership defaultProvider="MyProvider" userIsOnlineTimeWindow="25">
    Line 114:    <providers>
    Line 115:      <add name="MyProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ConnectionString2" applicationName="/" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>


    I am using Visual Web developer 2008 Express Edition.  My ASP.Net Web Application Administrator shows the following (default values) ont he "Provider" tab:

     

    Use this page to configure how Web site management data such as membership is stored. You can use a single provider for all the management data for your site or you can specify a different provider for each feature.

    Your application is currently configured to use the provider: AspNetSqlProvider

    Select a single provider for all site management data
    Select a different provider for each feature (advanced)

    Any direction appreciated...

    Eric Speicher
  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-04-2009, 8:59 AM
    • Member
      51 point Member
    • _Degan_
    • Member since 04-19-2008, 3:41 PM
    • Posts 38

    anas:

     Hi,

    You don't have to change the membersdhip settings.By default ,Membership provider doesn't allow duplicate emails.This is because "RequiresUniqueEmail" property is true by default.

    Are you using the SqlMembershipProvider ???

    I am using AspNetSqlProvider, the default value generated by Visual WebDeveloper 2008 Express Edition.

    I do need to make some change as the membership provider is allowing duplicate email addresses.  I have duplicate email addresses in my membership.  I use the administration tool to delete these accounts and then contact the users manually via email.

    Eric Speicher
  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-04-2009, 9:13 AM
    • Star
      13,971 point Star
    • yasserzaid
    • Member since 09-22-2007, 9:10 PM
    • Egypt
    • Posts 2,597

    Hi

    did you try my post ?

  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-04-2009, 9:38 AM
    • Member
      51 point Member
    • _Degan_
    • Member since 04-19-2008, 3:41 PM
    • Posts 38

    yasserzaid:

    Hi

    did you try my post ?

    Yes, please see the error message in my post above when I add these sections you suggested to my web.config.  Perhaps I have added them incorrectly?

    Eric Speicher
  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-04-2009, 10:54 AM
    • Member
      51 point Member
    • _Degan_
    • Member since 04-19-2008, 3:41 PM
    • Posts 38

    At present, I have a work-around, but I would still like to understand this better and do it in the correct way.

     I have altered the Stored Procedure: aspnet_Membership_CreateUser adding the line:

    SET @UniqueEmail = 1

    This hits against a check for the new value against any of the exting values and propery bubbles up to the GUI.  I could not find where this SP is called.  If anyone knows how to control this properly I look forward to an answer.

    Eric Speicher
  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-04-2009, 3:16 PM
    • Star
      13,971 point Star
    • yasserzaid
    • Member since 09-22-2007, 9:10 PM
    • Egypt
    • Posts 2,597

    Hi

    try my post and tell me if your problem still or not

    Good Luck

  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-04-2009, 3:31 PM
    • Member
      51 point Member
    • _Degan_
    • Member since 04-19-2008, 3:41 PM
    • Posts 38

    yasserzaid:

    Hi

    try my post and tell me if your problem still or not

    Good Luck

     

    I still have a problem.  When I add the sections you have specified to the web.config, I get the error as described previously when attempting any page that uses the membership provider.

    Eric Speicher
  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-05-2009, 12:02 PM
    • Member
      51 point Member
    • _Degan_
    • Member since 04-19-2008, 3:41 PM
    • Posts 38

    Attempting to simply things I added part of the section to my web.config:

    <membership defaultProvider="MyProvider" userIsOnlineTimeWindow="25">

    <providers>

    <add name="MyProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ConnectionString2" applicationName="/" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>

    </providers>

    </membership>

    I get the following errors:

    Message 2 Could not find schema information for the element 'membership'. C:\Documents\Visual Studio 2008\Projects\FieldBaron\FieldBaron\Web.config 113 4 FieldBaron
    Message 3 Could not find schema information for the attribute 'defaultProvider'. C:\Documents\Visual Studio 2008\Projects\FieldBaron\FieldBaron\Web.config 113 15 FieldBaron

    And so on... 


     

    Eric Speicher
  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-05-2009, 12:16 PM
    Answer
    • All-Star
      61,685 point All-Star
    • anas
    • Member since 09-21-2006, 8:31 AM
    • Palestinian Territory, Occupied
    • Posts 6,930
    • Moderator

     Two things :

    1. The <membership> section should be placed inside the <system.web> section and not directly inside <configuration> section as you did.
    2. If there is xml name space in for the <configuration> section , remove it <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    Regards,

    Anas Ghanem | Blog

  • Re: Disallow duplicate email addresses in CreateUserWizard

    04-05-2009, 1:50 PM
    • Member
      51 point Member
    • _Degan_
    • Member since 04-19-2008, 3:41 PM
    • Posts 38

    anas:

     Two things :

    1. The <membership> section should be placed inside the <system.web> section and not directly inside <configuration> section as you did.
    2. If there is xml name space in for the <configuration> section , remove it <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

     

    That was it.  Thank you for your patience

    Eric Speicher
  • Re: Disallow duplicate email addresses in CreateUserWizard

    05-14-2009, 10:42 PM

    you can also see/set  the properties in iis > asp.net tab > edit configuration > Authentication

Page 1 of 1 (14 items)