SIGN UP MEMBER LOGIN:    
ARTICLE

Configuring MOSS 2007 Anonymous site to use ASP.NET Membership Provider

Posted by Bhushan Gawale Articles | SharePoint August 06, 2010
In my previous post I explained steps about how to create anonymous web site using SharePoint existing site. So in this post I am going to make use of out of the box ASP.NET Membership Provider and it to anonymous site which we created.
Reader Level:

Hi again in this anonymous site series.. 

In my previous post I explained steps about how to create anonymous web site using SharePoint existing site. So in this post I am going to make use of out of the box ASP.NET Membership Provider and it to anonymous site which we created. (This is easy one)

So very first step is to have ASPNET db in SQL Server, and for this we are going to use the traditional ASP.NET way with popular command aspnet_regsql

1. Open visual studio command prompt and type in command aspnet_regsql, you will see ASP.NET Sql Server setup wizard, click next and select configure SQL Server for application services.

Enter Database Server name and keep database name as <default> in dropdown (this will create db with name aspnetdb in SQL Server), click finish on next screen

2. Once aspnetdb database is created in SQL Server, then next step is to make use of this db.  

Browse to Central Administration site and click on Application Management tab. Find and click on Authentication Providers, select Internet zone.  Change Authentication type to Forms , and enter Membership Provider Name as AspNetSqlMembershipProvider and Role Manager Name as AspNetSqlRoleProvider. Click on save.

1.gif 

3. Now we have configured anonymous application to use Forms authentication, next step is to specify Membership provider and role manager entries in web.config file of anonymous web site

Add following entries to web.config file

<membership>
      <providers>
        <add name="AspNetSqlMembershipProvider " type="System.Web.Security.SqlMembershipProvider,System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordFormat="Hashed" applicationName="/" />
      </providers>
</membership>        

<roleManager>
      <providers>
        <remove name="AspNetSqlRoleProvider" />
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider,System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" role="SignedInClient" applicationName="/" />
      </providers>
</roleManager>

<connectionStrings>
    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="Data Source=DbServer;Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

Connection string is required for application to know about aspnetdb.

4. Now , to register users with anonymous site you can use out of box ASP.NET user registration wizard control and Login control , so there are two ways to achieve this 
  • You can create your custom page layouts and add those ASP.NET controls to page layouts like this 

    For Login Page: 

    <
    asp:Login runat="server" ID="Login1" DestinationPageURL="/Pages/Default.aspx" CreateUserText="Create User" CreateUserUrl="/Pages/Registration.aspx"></asp:Login>

    For Registration Page:

    <
    asp:CreateUserWizard ID="CreateUserWizard2" runat="server" ContinueDestinationPageUrl="/Pages/Default.aspx">
          <WizardSteps>
           <asp:CreateUserWizardStep ID="CreateUserWizard1" runat="server" />
           <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server" />
          </WizardSteps>
    </asp:CreateUserWizard>

  • Or you can create your web parts wrapping OOB ASP.NET controls and add them to your site

    Login WebPart :

    protected
    override void CreateChildControls()
    {
        try
        {
            base.CreateChildControls();
            Login loginControl = new Login();
            loginControl.DestinationPageUrl = "/Pages/Default.aspx";
            loginControl.CreateUserUrl = "/Pages/Registration.aspx";
            this.Controls.Add(loginControl);
        }
        catch (Exception ex)
        {
        }
    }

    Registration WebPart:

    protected
    override void CreateChildControls()
    {
        try
        {
            base.CreateChildControls();
            CreateUserWizard cwz = new CreateUserWizard();
            cwz.ContinueDestinationPageUrl = "/Pages/Default.aspx";
            this.Controls.Add(cwz);
        }
        catch (Exception ex)
        {
        }
    }

Note: there are many properties of these controls which you can configure as your need

5. Once you have set up all these things and have your custom login page then , change default login page of anonymous site using IIS Manager like this 
Find anonymous site in IIS > find authentication in features view >right click on Forms Authentication> click edit > change login url 

2.gif
 
Above all settings worked pretty perfectly for me (at least) 

Reference best Links: This and This

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor