Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...how to set password for user how to set password for user 'host' (common question when we forgot the password)
Previous
 
Next
New Post
3/30/2010 2:46 PM
 

This is the common question when we forgot the password of user 'host'.

 The difficult is : Dotnetnuke use AspNetSqlMembershipProvider for user administration, this provider gives us theses functions bellow :

- ChangePassword(username, oldPassword, newPassword);

- ChangePasswordQuestionAndAnswer(username, password, newPasswordQuestion, newPasswordAnswer);

- ChangePassword(userInfo, oldPassword, newPassword)

We have the function SetPassword(userInfo , newPassword ) but it not works.
 
 
I will provide other solution :
 
1/ using this statement for get all username anh userid
 
string strSQL = @"SELECT     u.UserName, ms.Password, ms.PasswordFormat, ms.PasswordSalt, u.UserId
                        FROM aspnet_Users AS u INNER JOIN
                        aspnet_Membership AS ms ON u.UserId = ms.UserId";
 
an then use this for change the password of all user (host and other):
 
string strSQL = "SELECT PasswordSalt from aspnet_Membership where UserId='" + userid + "'";
object oPasswordSalt = DataFactory.ExecuteScalar(strSQL);
Crypto cy = new Crypto();
string password = cy.Encode(txtPassword.Text, oPasswordSalt.ToString());
strSQL = "update aspnet_membership set password='" + password + "' where userid='" + userid + "'";
DataFactory.Execute(strSQL);
Response.Write("<script> K!');</script>");
 
the class 'Crypto' i will provider after.
 
 
 
New Post
3/30/2010 4:53 PM
 

this is the source code of class Crypto
----------
using System;
    using System.Reflection;
    using System.Text;
    using System.Web.Configuration;
    using System.Web.Security;

    public class Crypto
    {
        public Crypto()
        {
        }

        // Fields
        private MethodInfo _EncDecMethod = null;

        // Methods
        public string Decrypt(string data)
        {
            string str;
            Initialize();
            try
            {
                byte[] buffer = Convert.FromBase64String(data);
                object[] parameters = new object[5];
                parameters[0] = false;
                parameters[1] = buffer;
                parameters[3] = 0;
                parameters[4] = buffer.Length;
                byte[] bytes = (byte[])_EncDecMethod.Invoke(null, parameters);
                str = Encoding.UTF8.GetString(bytes);
            }
            catch
            {
                throw new Exception("Failed to encrypt data.");
            }
            return str;
        }

        public string Encrypt(byte[] bytes)
        {
            string str = "";
            Initialize();
            try
            {
                object[] parameters = new object[5];
                parameters[0] = true;
                parameters[1] = bytes;
                parameters[3] = 0;
                parameters[4] = bytes.Length;
                byte[] inArray = (byte[])_EncDecMethod.Invoke(null, parameters);
                str = Convert.ToBase64String(inArray);
            }
            catch
            {
                throw new Exception("Failed to encrypt data.");
            }
            return str;
        }

        private void Initialize()
        {
            try
            {
                _EncDecMethod = typeof(MachineKeySection).GetMethod("EncryptOrDecryptData",
                    BindingFlags.NonPublic | BindingFlags.Static,
                    Type.DefaultBinder,
                    new Type[] { typeof(bool), typeof(byte[]), typeof(byte[]), typeof(int), typeof(int) }, null);
            }
            catch
            {
                throw new Exception("Failed to initialized base encryption method.");
            }
        }

        public string Encode(string pass, string salt)
        {
            byte[] bytes = Encoding.Unicode.GetBytes(pass);
            byte[] src = Convert.FromBase64String(salt);
            byte[] data = new byte[src.Length + bytes.Length];
            Buffer.BlockCopy(src, 0, data, 0, src.Length);
            Buffer.BlockCopy(bytes, 0, data, src.Length, bytes.Length);

            string s = Encrypt(data);
            return s;
        }
    }
-----------

for more detail : http://coder.awas.vn/Home/Topic/353-Dat-mat-khau-cho-tai-khoan-host-cua-DNN.aspx

 
New Post
3/30/2010 6:31 PM
 
if you have access to the database, you may follow this procedure: http://www.deutschnetnuke.de/tabid/183/Default.aspx

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
3/31/2010 12:45 AM
 
@Sebastian : The diffrent is, you dont have to follow the rule of DNN pass word. You can enter only one letter "1" for your password or leave blank. And we dont have to create a new member eachtime we forgot the password of admin.
 
New Post
3/31/2010 3:25 AM
 
nguyen khanh wrote:
And we dont have to create a new member eachtime we forgot the password of admin.
I hope, it doesn't happen too frequently per installation ;)

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...how to set password for user how to set password for user 'host' (common question when we forgot the password)


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out