Wednesday, June 30, 2010

DNN programmatically login user

PortalSettings currentPortal = PortalController.GetCurrentPortalSettings();

UserLoginStatus loginStatus = new UserLoginStatus();

UserInfo objUser = UserController.ValidateUser(
currentPortal.PortalId,
ConfigurationSettings.AppSettings["DnnLoginUser"],
ConfigurationSettings.AppSettings["DnnLoginPassword"],
"DNN", "",
currentPortal.PortalName, HttpContext.Current.Request.UserHostAddress, ref loginStatus);

if (loginStatus == UserLoginStatus.LOGIN_SUCCESS)
{
UserController.UserLogin
(currentPortal.PortalId,
objUser, currentPortal.PortalName,
HttpContext.Current.Request.UserHostAddress, false);
}

No comments: