Ok, it works.
Below the event in the global.asax. It is only fired when authentication succeeded, the authenticated user is available in the handler argument:
public void WebSsoAuthenticationModule_Authenticate(object sender, WebSsoAuthenticationEventArgs e)
{
using (StreamWriter w = new StreamWriter(@"e:\authentication3.log"))
{
w.WriteLine(e.Identity.Name);
}
}
It took me hours to find out how the event handler has to look. Using reflector I found the answer. Global.asax event handlers are coupled to events of http modules by using the key of the module. The key is configured in the web.config:
For ADFS the default configuration looks like this.
<httpModules>
<add
name="Identity Federation Services Application Authentication Module"
type="System.Web.Security.SingleSignOn.WebSsoAuthenticationModule, System.Web.Security.SingleSignOn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null" />
</httpModules>
The key is then "Identity Federation Services Application Authentication Module". In the global.asax a method should be created with this name. Of course this is not possible because it's not allowed to create method names with spaces. Therefore you have to change the name. If you change it to WebSsoAuthenticationModule. The global.asax method is:
public void WebSsoAuthenticationModule_Authenticate(object sender, WebSsoAuthenticationEventArgs e)
{
}
Regards,
René