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.

About the Author

Adnan Zameer, Lead Developer at Optimizley UK, is a certified Microsoft professional, specializing in web app architecture. His expertise includes Optimizley CMS and Azure, showcasing proficiency in crafting robust and efficient solutions.

0 comments :

Post a Comment