Other login option for DNN


/ Published in: C#
Save to your folder(s)

This is another login method, a little more robust


Copy this code and paste it in your HTML
  1. protected void lnkLogin_Click(object sender, EventArgs e)
  2. {
  3. string AuthType = "DNN";
  4.  
  5. DotNetNuke.Security.Membership.UserLoginStatus status = new DotNetNuke.Security.Membership.UserLoginStatus();
  6. DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.ValidateUser(PortalId, txtUser.Text, txtPassword.Text, AuthType, "", PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), ref status);
  7. bool success = true;
  8. switch (status)
  9. {
  10. case DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUCCESS:
  11. UserInfo.Membership.Password = txtPassword.Text;
  12. UserInfo.Username = txtUser.Text;
  13.  
  14. DotNetNuke.Entities.Users.UserController.UserLogin(PortalId, UserInfo, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true);
  15. break;
  16. case DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUPERUSER:
  17. UserInfo.Membership.Password = txtPassword.Text;
  18. UserInfo.Username = txtUser.Text;
  19.  
  20. DotNetNuke.Entities.Users.UserController.UserLogin(PortalId, UserInfo, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true);
  21. break;
  22. default:
  23. //showerror
  24. success = false;
  25. break;
  26. }
  27. if (success)
  28. {
  29. Response.Redirect(Request.RawUrl);
  30. }
  31. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.