What is the best way to provide a way to lock and unlock a user account from an application?
I have an administration area, where an admin could do some operations about an user account, and one of them would be to temporary lock/unlock the user account.
So, if he is locked he couldn't authenticate on the application until he is unlocked again.
I'm using ActiveDirectoryMemberhipProvider!
I was thinking on create a "suspended" role, and add the user to this role if the admin locks his account, and then deny the access to the appliaction if the user is in this role.
Is there a better way to do this? I'm still learning... [:)]
I use a drop down that selects all users that are locked. Then I placed a button next to the drop down and that calls this code. Using this statement in the drop down
SELECT [UserName] FROM [vw_aspnet_MembershipUsers] WHERE ([IsLockedOut] = @IsLockedOut) ORDER BY [UserName]
When I click on the button it calls this Statement.
Dim mu As MembershipUser = Membership.GetUser(ddlLockedUsers.SelectedItem.Text)
mu.UnlockUser()
Membership.UpdateUser(mu)
Hope that helps.
Please remember to mark your post as "Resolved" when it is solved, and mark as "Answer" the post(s) that solved it!
I don't know where the framework allows you to lock the user. The only thing I can think of is actually creating an SQL Statement.
Locking and Unlocking users are ment to be for the systems control. Since you are not the system, why no use the approve and unapprove features. They do the exact same thing as locking and unlock. But the approved and unapproved feature in the framework
is easily accessible unlike locking a user. The only current way I know to lock a user is when they fail the login more than 3 times(custom setting). As far as it being in the framework, it might be but I have not found it yet. If you really must lock the
user instead of unapprove the user, then you need to do an SQL statement and if you decide to go hunting for the locking capabilities, let me know where in the framework it is when you find it. I know allot of people struggle with this particular subject.
Please remember to mark your post as "Resolved" when it is solved, and mark as "Answer" the post(s) that solved it!
I just want a way to temporary block an user from the application. I think the best way to call this is to
suspend the user account. So, when an user is suspended he can't authenticate on the application and it can give him some message like "your account is temporary suspended!". And when the admin removes the suspension he can pass through the
authentication.
Best Regards
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
the user will be suspended in webapplication... or any authentication on webapplication.
No. I've tested this situation and it's like I was thinking.. If I use the IsApproved property it suspends the user on the Web Application and Active Directory.
I just want to suspend a user on the Web Application. Anyone have more ideas?
cseven
Member
23 Points
139 Posts
Lock/Unlock User Account
Nov 08, 2007 03:49 PM|LINK
Hi,
What is the best way to provide a way to lock and unlock a user account from an application?
I have an administration area, where an admin could do some operations about an user account, and one of them would be to temporary lock/unlock the user account.
So, if he is locked he couldn't authenticate on the application until he is unlocked again.
I'm using ActiveDirectoryMemberhipProvider!
I was thinking on create a "suspended" role, and add the user to this role if the admin locks his account, and then deny the access to the appliaction if the user is in this role.
Is there a better way to do this? I'm still learning... [:)]
Thanks!
cheetahtech
Member
348 Points
130 Posts
Re: Lock/Unlock User Account
Nov 08, 2007 05:34 PM|LINK
I use a drop down that selects all users that are locked. Then I placed a button next to the drop down and that calls this code. Using this statement in the drop down
SELECT [UserName] FROM [vw_aspnet_MembershipUsers] WHERE ([IsLockedOut] = @IsLockedOut) ORDER BY [UserName]
When I click on the button it calls this Statement.
Dim mu As MembershipUser = Membership.GetUser(ddlLockedUsers.SelectedItem.Text) mu.UnlockUser() Membership.UpdateUser(mu)Hope that helps.
cseven
Member
23 Points
139 Posts
Re: Lock/Unlock User Account
Nov 09, 2007 08:54 AM|LINK
I knew that method, and that's a way to unlock, but how do you manually lock an account?
Thanks for the reply [;)]
cseven
Member
23 Points
139 Posts
Re: Lock/Unlock User Account
Nov 09, 2007 08:54 AM|LINK
(Duplicated, and I can't delete it [:$], sorry!)
cheetahtech
Member
348 Points
130 Posts
Re: Lock/Unlock User Account
Nov 09, 2007 12:59 PM|LINK
I don't know where the framework allows you to lock the user. The only thing I can think of is actually creating an SQL Statement.
Locking and Unlocking users are ment to be for the systems control. Since you are not the system, why no use the approve and unapprove features. They do the exact same thing as locking and unlock. But the approved and unapproved feature in the framework is easily accessible unlike locking a user. The only current way I know to lock a user is when they fail the login more than 3 times(custom setting). As far as it being in the framework, it might be but I have not found it yet. If you really must lock the user instead of unapprove the user, then you need to do an SQL statement and if you decide to go hunting for the locking capabilities, let me know where in the framework it is when you find it. I know allot of people struggle with this particular subject.
cseven
Member
23 Points
139 Posts
Re: Lock/Unlock User Account
Nov 09, 2007 04:51 PM|LINK
Hi,
I just want a way to temporary block an user from the application. I think the best way to call this is to suspend the user account. So, when an user is suspended he can't authenticate on the application and it can give him some message like "your account is temporary suspended!". And when the admin removes the suspension he can pass through the authentication.
I don't know if i'm explaining well what need...
XiaoYong Dai...
All-Star
38310 Points
4229 Posts
Re: Lock/Unlock User Account
Nov 12, 2007 07:41 AM|LINK
Hi
What about get/set membershipUser.IsApproved property? Here is an example might help
http://forums.asp.net/p/1140620/1838975.aspx#1838975
XiaoYong Dai
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
cseven
Member
23 Points
139 Posts
Re: Lock/Unlock User Account
Nov 12, 2007 09:55 AM|LINK
And I can use the IsApproved property on ActiveDirectoryMembershipProvider?
If yes, the user will be "suspended" just on the web application or on the AD as well?
Thanks!
naturehermit
Star
14610 Points
3046 Posts
Re: Lock/Unlock User Account
Nov 12, 2007 10:37 AM|LINK
the user will be suspended in webapplication... or any authentication on webapplication.
cseven
Member
23 Points
139 Posts
Re: Lock/Unlock User Account
Nov 13, 2007 10:17 AM|LINK
No. I've tested this situation and it's like I was thinking.. If I use the IsApproved property it suspends the user on the Web Application and Active Directory.
I just want to suspend a user on the Web Application. Anyone have more ideas?