I googled and found following article that described how to solve the same issue for CRM 4.0 that was written by MVP fellow Dylan Haskins (thanks a lot, I owe you a beer). Here are steps to replace LiveId authentication with Forms authentication (I assume that you’ve already configured Customer Portal):
1. Open web.config file and find following text:
<authentication mode="None"/>
<authentication mode="Forms"> <forms name=".ASPXAUTH" loginUrl="login" defaultUrl="default.aspx" protection="All" timeout="30" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseDeviceProfile" domain="" enableCrossAppRedirects="false"> </forms> </authentication>
<%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.master" AutoEventWireup="True" CodeBehind="Login.aspx.cs" Inherits="Site.Pages.Login" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentBottom" runat="server"> <asp:Login ID="Login1" runat="server" onauthenticate="Login1_Authenticate"> </asp:Login> </asp:Content>
using System; using System.Web.Security; using Xrm; using System.Linq; using Microsoft.Xrm.Portal; using Microsoft.Xrm.Portal.Configuration; using Microsoft.Xrm.Portal.Access; using Microsoft.Xrm.Portal.Cms; using Microsoft.Xrm.Portal.Core; namespace Site.Pages { public partial class Login : PortalPage { private Contact _loginContact; protected Contact LoginContact { get { if (_loginContact != null) { return _loginContact; } _loginContact = XrmContext.ContactSet .FirstOrDefault(c => c.Adx_username == Login1.UserName && (c.Adx_password == Login1.Password)); XrmContext.Detach(_loginContact); return _loginContact; } } protected void Page_Load(object sender, EventArgs e) { if ((User != null && User.Identity != null) && User.Identity.IsAuthenticated) { var redirectUrl = !string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]) ? Request["ReturnUrl"] : !string.IsNullOrEmpty(Request.QueryString["URL"]) ? Request["URL"] : "/"; Response.Redirect(redirectUrl); } } protected void Login1_Authenticate(object sender, System.Web.UI.WebControls.AuthenticateEventArgs e) { if (LoginContact == null) { e.Authenticated = false; } else { if (LoginContact.Adx_username == Login1.UserName) { if (LoginContact.Adx_changepasswordatnextlogon.Value) { var portal = PortalCrmConfigurationManager.CreatePortalContext(); var website = (Adx_website)portal.Website; var page = (Adx_webpage)portal.ServiceContext.GetPageBySiteMarkerName(portal.Website, "ChangePassword"); string redirectURL = page.Adx_PartialUrl + "?UserName=" + Server.UrlEncode(Login1.UserName) + "&Password=" + Server.UrlEncode(Login1.Password); Response.Redirect(redirectURL); } else { LoginContact.Adx_LastSuccessfulLogon = DateTime.Now; XrmContext.Attach(LoginContact); XrmContext.UpdateObject(LoginContact); XrmContext.SaveChanges(); XrmContext.Detach(LoginContact); e.Authenticated = true; FormsAuthentication.RedirectFromLoginPage(Login1.UserName, true); } } else { e.Authenticated = false; } } } } }
using System; using System.Linq; using Microsoft.Xrm.Portal.Access; using Microsoft.Xrm.Portal.Cms; using Microsoft.Xrm.Portal.Core; using Microsoft.Xrm.Portal.Web; using Xrm; using System.Web.UI.WebControls; using Site.Library; using System.Web.Security; using Microsoft.Xrm.Portal.Configuration; namespace Site.Pages { public partial class Logout : PortalPage { protected void Page_Load(object sender, EventArgs e) { FormsAuthentication.SignOut(); var portal = PortalCrmConfigurationManager.CreatePortalContext(); var website = (Adx_website)portal.Website; var page = (Adx_webpage)portal.ServiceContext.GetPageBySiteMarkerName(portal.Website, "Home"); Response.Redirect(page.Adx_PartialUrl); } } }
<asp:LinkButton ID="LogoutLink" runat="server" Text='<%$ Snippet: links/logout, Logout %>' OnClick="LogoutLink_Click"/>
<asp:HyperLink ID="LogoutLink" runat="server" Text='<%$ Snippet: links/logout, Logout %>' NavigateUrl="/Pages/logout.aspx"/>
7. For test purposes create a contact in CRM:
8. Open Customer Portal and try to log in:
That’s it and in case you are too lazy to do provided steps you can find source code of a project here:



