DotNetNuke – How to reset host password

DNN

I love to talk about DotNetNuke in this blog, and I’ve already did it a bunch of times (I guess). Well, I like it and I’ve been using it since the 2nd version, when it still supported MS Access databases. It was a long time ago. I will not extend myself. All you have to know about this amazing tool, you can read in the official website: http://www.dnnsoftware.com/.

Even the most experienced DotNetNuke’s users needs to handle some issues that are impossible to do, even using the administration area. Neither the SQL prompt page can help. The only way is coding, perhaps, a DotNetNuke Module. Hopefully, the ASP.NET gave to us the possibility to write “Code In Page” .aspx files and, the best part of it is, you can use all classes available in the website where it runs. So, lets use it for a very unusual trick that almost every DotNetNuke’s administrator once in their lives must needs it. Reset/redefine the host user password.

The .aspx page can be written in C# or VB.NET, it’s a matter of taste. The code bellow redefines the host password to a new one:

<!DOCTYPE html>
<%@ Page Language="C#" %>
<script runat="server">
	void Page_Load(object sender, System.EventArgs e)
	{
		DotNetNuke.Entities.Users.UserInfo user = DotNetNuke.Entities.Users.UserController.GetUserByName("host");
 
		if (user != null)
		{
			DotNetNuke.Entities.Users.UserController.ResetPasswordToken(user);
			var passwordChanged = DotNetNuke.Entities.Users.UserController.ChangePasswordByToken(user.PortalID, user.Username, "[novasenhadohost]", user.PasswordResetToken.ToString());
 
			if(passwordChanged)
			{
				Response.Write("Senha alterada com sucesso");
			}
			else
			{
				Response.Write("Não foi possível alterar a senha.");
			}
 
		}
		else
		{
			Response.Write("Usuário não encontrado");
		}
 
	}
</script>
<html lang="pt-BR">
	<head>
		<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
		<title>Redefinindo a senha do host</title>
	</head>
 
	<body>
	</body>
</html>

That is all you need. Just upload this .aspx into your DotNetNuke installation folder and runs the page in your web browser. After this, the host password will be changed to “[newhostpassword]”, or whatever you want. It saves a lot of your time.

I’ve tested this code under the versions 5, 6 and 7 of DotNetNuke .

Enjoy!

Vídeo Dicas Rápidas – Inserindo imagens em comentários no Excel


Salve pessoal! Mais um vídeo da seção Dicas Rápidas! Desta vez, vamos explorar um recurso existente no Excel e estendê-lo em nosso favor. Comentários em células com imagens!

Aproveite para se inscrever no canal e ficar de olho em todas as novidades que são publicadas: http://youtube.com/tomamais

Bom proveito!

VBA – How to avoid Auto_Open execution and similars

Auto_Open

We love macros (well, I love them!). They save our lives automating the most annoying part of our job. Macros are the best! But, it depends on what kind of macros we’re talking about.

Here, the annoying macros are knowing as “auto started macros”, mainly, the Auto_Open Sub. I’ve already described how it works in this post. In a nutshell, the Auto_Open Sub executes when the application starts. The most common usage of this special Subs are present some information or alerts about the application, splash screens and, of course, the annoying part, turns the Excel invisible, hides toolbars, disables shortcuts, etc. After this, it’s impossible to have access to VBA IDE, check the code, debug and so on.

Unfortunately, disable the macros is not an option because of you can’t reactivate them unless you close and open the workbook again.

Fortunately, there is an easy, actually, super easy way to avoid the Auto_Open Sub execution, even with macros enabled. Try to open the workbook holding the Shitf key, choosing the “Enable macros” option.

Enable Macros

And here it is! There are no differences besides the fact that the Auto_Open will not execute. Everything else will work perfectly. If the code inside the Auto_Open is essential for the application, you can execute it manually.

Enjoy!

Video Dicas Rápidas – Repetindo ações no Office com F4


Salve pessoal! Mais um vídeo da seção Dicas Rápidas! É hora de acelerar os trabalhos com o atalho F4! Veja o vídeo e fique ligado e mais essa dica!

Aproveite para se inscrever no canal e ficar de olho em todas as novidades que são publicadas: http://youtube.com/tomamais

Bom proveito!