I have extended my HTTPModule to try and modified the code that is in the cmdLogin_Click code. The site still redirects in a way that will never resolve. The code is as follows:
public class SSO_Module:IHttpModule
{
#region IHttpModule Members
public void Init(HttpApplication context)
{
context.AuthorizeRequest += new EventHandler(context_AuthorizeRequest);
}
void context_AuthorizeRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
SSO.SingleSignOnIdentity id = (SSO.SingleSignOnIdentity)app.User.Identity;
app.Response.Write("IsAuthenticated:" + id.IsAuthenticated.ToString() + "
");
app.Response.Write("Name:" + id.Name + ", " + id.NameType + "
");
app.Response.Write("
Claims
");
foreach (SecurityProperty sp in id.SecurityPropertyCollection)
{
app.Response.Write(sp.Name + " - " + sp.Value +"
");
}
try
{
UserCreateStatus objUserCreateStatus;
//'See if user exists in DNN Portal user DB
UserInfo objUserInfo = UserController.GetUserByName(0, id.Name);
//' user does exist - try to create on the fly
if (objUserInfo == null)
{
objUserInfo = new UserInfo();
objUserInfo.DisplayName = id.Name;
objUserInfo.FirstName = id.Name;
objUserInfo.LastName = id.Name;
objUserInfo.Username = id.Name;
objUserInfo.Membership.Password = "reallyhardpassword";
objUserInfo.PortalID = 0;
objUserInfo.Email = id.Name;
objUserCreateStatus = UserController.CreateUser(ref objUserInfo);
if (objUserCreateStatus == UserCreateStatus.Success)
{
LetsLogUserIn(objUserInfo, app.Response);
}
else
{
objUserInfo = null;
}
}
else
{
LetsLogUserIn(objUserInfo, app.Response);
}
//app.Response.Write("leaving check dnn user for " + objUserInfo.DisplayName);
}
catch (Exception ex)
{
//DotNetNuke.Services.Exceptions.LogException(ex);
}
}
private void LetsLogUserIn(UserInfo objUserInfo, HttpResponse response)
{
try
{
//'Lets log the user in
UserLoginStatus loginStatus;
response.Write(
"Login check dnn user: current/checking " +
"/" + objUserInfo.Username);
Localization.SetLanguage(DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().DefaultLanguage);
response.Write("Log them in - INFO coming....");
response.Write("Log them in user/potal/pid " + objUserInfo.Username);
UserController.UserLogin(0,
objUserInfo,
"My Website",
HttpContext.Current.Request.UserHostAddress,
false);
response.Write("Logged in completed");
}
catch(Exception ex)
{
//DotNetNuke.Services.Log.EventLog.logex.Services.Exceptions.LogException(ex);
}
}
Any help would be greatly appreciated