Thanks. I managed to do it with some modifications to the code from the URL you posted.
In case someone needs it here it is ( the code is not complete, I still need to add a message when the login or password is wrong, etc.. ) :
protected void lnkLogin_Click(object sender, EventArgs e)
{
string AuthType = "DNN";
DotNetNuke.Security.Membership.UserLoginStatus status = new DotNetNuke.Security.Membership.UserLoginStatus();
DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.ValidateUser(PortalId, txtUsername.Text, txtPassword.Text, AuthType, "", PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), ref status);
switch (status)
{
case DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUCCESS:
UserInfo.Membership.Password = txtPassword.Text;
UserInfo.Username = txtUsername.Text;
DotNetNuke.Entities.Users.UserController.UserLogin(PortalId, UserInfo, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true);
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
break;
case DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUPERUSER:
UserInfo.Membership.Password = txtPassword.Text;
UserInfo.Username = txtUsername.Text;
DotNetNuke.Entities.Users.UserController.UserLogin(PortalId, UserInfo, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true);
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
break;
default:
break;
}
}