Pardon the mess of the posted code... but it should serve as an example:
protected void Page_Load(System.Object sender, System.EventArgs e)
{
if (Request.UserHostAddress != null)
_ipAddress = Request.UserHostAddress;
try
{
if (!Page.IsPostBack)
{
if (Session["AutoLogonProcess"] != null)
return;
else
Session["AutoLogonProcess"] = true;
string fullUser = Request.ServerVariables["LOGON_USER"];
string userName = fullUser.ToLower().Replace(@"macu_nt\", "");
// see if user is already logged in...
if (this.UserInfo.UserID > 0)//this.User != null && this.User.UserID > 0)
{
}
else
{
// otherwise, log them in
UserInfo objUser = UserController.GetUserByName(this.PortalId, userName);
if (objUser != null && objUser.Membership.Approved && !objUser.Membership.LockedOut)
{
UserAuthorized(objUser, false);
}
}
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
private void UserAuthorized(UserInfo objUser, bool canProceed)
{
string strMessage = string.Empty;
bool updatePassword = false;
bool updateProfile = false;
UserId = objUser.UserID;
if ((!(objUser.Profile == null)) && (!(objUser.Profile.PreferredLocale == null)))
{
Localization.SetLanguage(objUser.Profile.PreferredLocale);
}
else
{
Localization.SetLanguage(PortalSettings.DefaultLanguage);
}
// check whether profile needs updating
if (!updatePassword && this.RequireValidProfile)
{
}
if (updatePassword)
{
}
else if (updateProfile)
{
}
else
{
// complete login
UserController.UserLogin(PortalId, objUser, PortalSettings.PortalName, _ipAddress, false);
try
{
int seconds = 0;
string url = string.Empty;
string port = Request.Url.IsDefaultPort ? string.Empty : ":" + Request.Url.Port.ToString();
if (_hasRedirectUrl)
{
if (RedirectURL.IndexOf("http") == -1)
url = "http://" + Request.Url.Host + port + RedirectURL;
else
url = RedirectURL;
}
else
{
url = "http://" + Request.Url.Host + port + Request.Url.Segments[0] + Request.Url.Segments[1];
}
Response.AppendHeader("Refresh", seconds.ToString() + "; URL=" + url); // give them a second or so to see the message, then redirect
}
catch (Exception ex)
{
AddModuleMessage(ex.ToString(), DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError, true);
}
}
}