Tuesday, 9 September 2014

DNN: Programmatically login user In DotNetNuke


In DotNetNuke if  you end up in a need to login user programmatically. You can use the following code

var loginStatus = new UserLoginStatus();

var objUser = UserController.ValidateUser(0, "host", "dnnhost", "", "", "0.0.0.0", ref loginStatus);

if (loginStatus != UserLoginStatus.LOGIN_FAILURE || loginStatus != UserLoginStatus.LOGIN_USERNOTAPPROVED)
{
   UserController.UserLogin
   (this.PortalId,
    objUser, PortalSettings.PortalName,
    HttpContext.Current.Request.UserHostAddress, false);
}


/Adnan


This post is from my old blog posted  on May 2012, that unfortunately no longer exist.

0 comments :

Post a comment