wjh
wjh

Reputation: 597

.net membership unsuspend account

I am using .net membership to manage my user roles. Currently users are suspended after a long period of inactivity. Is there a membership api to unsuspend the user?

Upvotes: 1

Views: 257

Answers (2)

Bui Cuong
Bui Cuong

Reputation: 149

If suspend and unsuspend here mean lock/unlock you can try:

MembershipUser user = Membership.GetUser("name");
user.UnlockUser();

Upvotes: 0

agarcian
agarcian

Reputation: 3963

There is no 'suspension' as such in the Membership Provider; however, there are two properties that will affect the ability of a user to login to the system:

In the MembershipUser class, let's look at:

MembershipUser.IsLockedOut: This property indicates that a user has been locked out of the system by trying to log in with the incorrect password more than the allowed number of times. The web.config would have that number.

Notice that you cannot explicitly lockout a user programmatically. Only a user herself can get locked out by trying incorrect passwords for her account.

MembershipUser.IsApproved: You can approve or disapprove a user and that property will define whether a user can be authenticated or not. This is probably the equivalent to a Suspended user. You simply set the MembershipUser.IsApproved to false and update the user with the MembershipProvider.UpdateUser(MembershipUser) method. Conversely, you would set the property IsApproved to true if you want to allow the user to log in again.

Hopefully, this will clarify the capabilities of the Membership provider, but it is strange to see that a user has been 'suspended' from the system due to inactivity. Are you sure it is not one of the two options discussed above?

Upvotes: 2

Related Questions