Operations when using profile and membership

Source: Internet
Author: User
Enter user background Formsauthentication. setauthcookie (strusername, False );
Response. Redirect ( " ../Member/index. aspx " , True );

Obtains the profile and membership information of a user.Membershipuser mu=Membership. getuser (strusername );
Profilecommon P=Profile. getprofile (strusername );

Modify user profile informationProfilecommon P=Profile. getprofile (strusername );
P. memberinfo. Name=Truename. text;
P. Save ();

Change User Password

If the old password is known, use the changepassword control to modify it.
If you do not know the old password and do not need requiresquestionandanswer, set enablepasswordreset of membership provider to "true" in Web. config, and then use:

Membershipuser mu = Membership. getuser (strusername );
Mu. changepassword (MU. resetpassword (), tbpsw. Text );

You can change the password.

Unlock user
The unlockuser method of membershipuser can be used to unlock the lock:Membershipuser mu=Membership. getuser (strusername );
If(MU. islockedout) mu. unlockuser ();

Note that, unlike isapproved, locking is caused by incorrect user operations and does not provide a way to set locking.

Set User status

Set through the isapproved attribute of membershipuser:

Membershipuser mu = Membership. getuser (strmember );
Mu. isapproved =   True ; // Set true or false based on actual conditions
Membership. updateuser (MU ); // You need to manually update the database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.