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 authentication provider based on Forms authentication. When an anonymous access a page which needs authentication, by the default behavior, the login page will be redirected.
My requirement is, when a user access a page for the first time in my SharePoint site which needs authentication,
if there is a special URL variable in current http session called "Identity", I want to treat the user as authenticated user and using the value of the "Identity" URL variable to be the authenticated user name of SharePoint (for example, accessing my SharePoint site by URL http://mysite/default.aspx?Identity=foo, then I will treat authenticated user "foo");
if there is a on URL variable in current http session variable called "Identity", the login page will be redirected to go through the default Forms authentication behavior.
Any ideas how to implement requirement 1 and 2?