Hi,
I am developing SharePoint 2010 application with custom login page based on Form Based Authentication. I am getting errorSPClaimsUtility.AuthenticateFormsUser System.ServiceModel.FaultException`1 was unhandled by user codewhen provides valid user information while login.
Below is code and exception traces.
CODE
using System; using System.Web.UI; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.IdentityModel; using Microsoft.SharePoint.IdentityModel.Pages; namespace HFTECH_InventorySystem.Layouts.InventorySystem { public partial class FBALogin : Page { protected void Page_Load(object sender, EventArgs e) { this.btnLogin.Click += new EventHandler(btnLogin_Click); } void btnLogin_Click(object sender, EventArgs e) { string UserName = txtUserName.Text; string Password = txtPassword.Text; //string Domain = txtDomainName.Text; string siteUrl = "http://localhost:13928"; Uri url = new Uri(SPContext.Current.Web.Url); bool ValidUser; ValidUser = SPClaimsUtility.AuthenticateFormsUser(url, UserName, Password); if (ValidUser) Response.Redirect(SPContext.Current.Web.Url); else lblError.Text = "Wrong UserID or Password."; } } }
EXCEPTION
SPClaimsUtility.AuthenticateFormsUser System.ServiceModel.FaultException`1 was unhandled by user code Message=Object reference not set to an instance of an object. Source=Microsoft.IdentityModel Action=http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault StackTrace: at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.ReadResponse(Message response) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst) at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForContext(Uri context, Boolean bearerToken, SecurityToken onBehalfOf, SecurityToken actAs, SecurityToken delegateTo) at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForFormsAuthentication(Uri context, String membershipProviderName, String roleProviderName, String username, String password) at Microsoft.SharePoint.IdentityModel.SPClaimsUtility.AuthenticateFormsUser(Uri context, String userName, String password) at IMP6101_InventorySystem.Layouts.InventorySystem.Login.btnLogin_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) InnerException:
Regards,
Mehar