Developing a custom authentication module for Outlook Web Access (OWA) 2010. For now, this module is always going to log in with a static userid (jdoe@staging.local); i.e. anybody accessing the OWA site should be automatically logged in with the jdoe id. Once I get this working, I can make the necessary mods.
I have developed a C Sharp class library that I think performs this. Code given below:
namespace MyAuth { public class AuthModule : IHttpModule { public void Dispose() { throw new NotImplementedException(); } public void Init(HttpApplication context) { context.PreRequestHandlerExecute += new EventHandler(this.OnAuthenticateRequest); } public void OnAuthenticateRequest(Object source, EventArgs e) { HttpApplication app = (HttpApplication)source; if (app.Context.User.Identity.IsAuthenticated == false) { WindowsIdentity identity = new WindowsIdentity("jdoe@staging.local"); WindowsPrincipal principal = new WindowsPrincipal(identity); app.Context.User = principal; } } } }
I have installed the module successfully. My problem is that the app crashes (server error) at the line
app.Context.User = principal.
If I comment that line (which basically means the module does nothing), the module works just fine. Any ideas on what I might be doing wrong ?