Sunday, October 11, 2009

DotNetNuke - Login control not working!

0 comments
Some time ago, Somebody emailed me regarding his strange problem. The dnn live website was throwing error and was not able to redirect to login page! So I asked him to login in host acount and uninstall openId authentication provider, because that's the dll that was causing proble. He was staring at and after some time he said, I'm getting error while logging in man!

I laughed a little and give following suggession:

Create a page Sample.aspx which inharits from DotNetNetNuke.Framework.Pagebase and in page load manually authenticate a user host using UserController.ValidateUser method. That will help you login to the site in host account and then delete the page one you are done.

So these kind of problems where host or admin user cannot login with their accounts can be solved by this simple sample page. But be remember to change the host password because we have to use that password in clear format to write the code. Here is the code that I used:

'Imports DotNetNuke.Security.Membership
Dim loginStatus As UserLoginStatus = UserLoginStatus.LOGIN_FAILURE
UserController.ValidateUser(PortalSettings.PortalId, "host", "xxx", PortalSettings.PortalName, "", PortalSettings.PortalName, AuthenticationLoginBase.GetIPAddress(), loginStatus)
Response.Redirect(NavigateUrl(PortalSettings.HomeTabId))