Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can anyone give me some idea about forget password issue..

i have a page and i made a custome user management..

and now i want that if some one forget a password

i gave him a textbox to write his email and as soon as he click on a forget password button the new password is saved to his database and an email is send to him on his email address having the same password saved to his database.

if some one know some better way to do this. then pls tell me..
thanks..
Posted

no - that is the best way. It allows you to keep him password as a hash, which means that it can't be read or restored, and lets the user get a new one. You should also provide some mechanism for the user to change his password, and also make the "new" password difficult to enter to encourage him to change it!

Personally, I use Guid.NewGuid().ToString() to generate the new password, but there is also the Membership.GeneratePassword method[^]
 
Share this answer
 
Comments
BobJanova 6-Sep-11 9:28am    
Who gave this a 1? O.o
codegeekalpha 6-Sep-11 17:45pm    
i am not using buldin user controls.. and i have my own database.. i can't use membership class..
OriginalGriff 7-Sep-11 3:22am    
Why? You just make things difficult for yourself. I too have my own database - and a Membership Porvider and Role provider of my own - that way the framework does the work for you, but you retain full control. Took about two hours to learn how and set up and test it, both locally and on the production server.
codegeekalpha 6-Sep-11 17:48pm    
by the way i wrote custome user managment.. all the answer are not of my match..i am managing users in my own way .. on the bases of my own coding and my owning database. not use asp administer website to controls my roles not using aspnet db ..
 
Share this answer
 
Comments
codegeekalpha 6-Sep-11 17:41pm    
i am not using asp bultin controls for usermanagement..
codegeekalpha 6-Sep-11 17:46pm    
i am not using asp built in user managament
i have my own database for user management.. i am managing roles myself.. i want to do it in a custom way.. with my own custome coding..
codegeekalpha 6-Sep-11 17:48pm    
by the way i wrote custome user managment.. all the answer are not of my match..i am managing users in my own way .. on the bases of my own coding and my owning database. not use asp administer website to controls my roles not using aspnet db ..
Monjurul Habib 7-Sep-11 3:07am    
share your detail code.
Try this

C#
public static string GetPasswordHash(string password)
        {
            byte[] _bytePassword = ASCIIEncoding.ASCII.GetBytes(password.Trim());
            _bytePassword = new SHA1CryptoServiceProvider().ComputeHash(_bytePassword);

            //do convert it to string for display & storing in DB
            int i;
            StringBuilder sbOutput = new StringBuilder(_bytePassword.Length);
            for (i = 0; i < _bytePassword.Length - 1; i++)
            {
                //build string array from byte array
                sbOutput.Append(_bytePassword[i].ToString("X2"));//"X2" is used to convert byte array to string
            }
            return sbOutput.ToString();
        }
 
Share this answer
 
Comments
BobJanova 6-Sep-11 9:29am    
This does not answer the question the OP asked.
Anuja Pawar Indore 6-Sep-11 9:43am    
Agree bob this is the way to generate a random password. Confirming a email and sending a password is the best practice.A suggestion for generating password
codegeekalpha 6-Sep-11 17:45pm    
?
codegeekalpha 6-Sep-11 17:48pm    
by the way i wrote custome user managment.. all the answer are not of my match..i am managing users in my own way .. on the bases of my own coding and my owning database. not use asp administer website to controls my roles not using aspnet db ..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900