views:

253

answers:

1

I have an ASP.Net application (on Win2K) that is using Windows authentication and impersonation. We are using the following code to change password:

Dim objDE As DirectoryEntry
'... 
objDE.Invoke("ChangePassword", txtOldPassword, txtNewPassword)

This code works great, except it does not lock the account if there were multiple unsuccessful attempts. Is there any way to make this code to lock the account if incorrect passwords was provided multiple times (as specified in a policy). I can't elevating user privileges, because this potentially makes the system less secure.

+1  A: 

I am not sure if a general user would have the permissions to directly lock their own account. However, one method to do such would be:

objDE.InvokeSet("IsAccountLocked", true)

For a great resource on .NET on Active Directory please see this article.

My appologies for the above link being in C#, if you need a good converter try this one.

codemonkeh
Unfortunately we cannot use this solution because it would require elevating user privileges which is not acceptable to us.
boredgeek
Can you not create a service account to perform authentication with? That account need not be able to interactively log-in. Another problem with using the users credentials to log in is that it is still possible even if their account is disabled!As a hack, though i hate to mention it, you could always lock their account by attempting to log in multiple times with an incorrect password.
codemonkeh
@Xian: The hack you suggested is actually a good idea. I was thinking along the same lines.
boredgeek