C# – ValidateUser of Forms Authentication issue

asp.netcforms-authenticationnetsharepoint-2007

I am using SharePoint 2007 Enterprise + Publishing portal template + Windows Server 2008. And I am developing using ASP.Net + C# + .Net 3.5 + VSTS 2008 on SharePoint Server 2007. I am developing a custom Forms authentication based on Forms authentication interface. I am learning using Forms Authentication with SharePoint and my confusion is about this method — ValidateUser of Forms Authentication, here is MSDN link,

http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.validateuser.aspx

My confusions are about which component will call ValidateUser method?

  1. Do I need to call ValidateUser by myself (my application code), or depends on my needs (not always needed, depends on my application scenario);
  2. Is ValidateUser is called by SharePoint code (not my own application code), if yes, when (i.e. in what situations will SharePoint calls ValidateUser method, or say in other words, what operation in SharePoint will trigger invocation of this method)?

thanks in advance,
George

Best Answer

The ValidateUser method is called to verify that a username and password have been correctly entered for a user. It is called during the authentication process.

If your web.config file is configured to use your custom membership provider ValidateUser is called automatically if

  • You use a standard control (like the ASP.NET Login control) for authentication in your page (this applies to both regular ASP.NET and SharePoint); or
  • You use the default SharePoint Forms Authentication page (/_layouts/login.aspx). SharePoint will redirect unauthenticated users to this page if the content being accessed is blocked for anonymous users.

You will have to call ValidateUser yourself if you customize the default SharePoint login page and you don't use the ASP.NET Login control.