Last post Jul 28, 2010 06:12 AM by ashiqf
Jul 27, 2010 07:50 AM|ruckumane|LINK
the directoryentry object with wrong password locks the user account and not able to log in again. pls anyone help me.
Jul 27, 2010 10:29 AM|integrasol|LINK
Well, you need to unlock the account, and I guess from your post that you're not the administrator of the server or network, right? If not, you need to contact the administrator to unlock the account. I'm also guessing that you've been trying more than once
with a wrong password, and subsequently the account got locked out. This is part of the policy for the server or network/domain, x number of invalid logon attempts locks out the user account. It may only be locked out for say 30 mins, after which the count
is also reset, but you need to contact the administrator to find out.
Jul 28, 2010 06:12 AM|ashiqf|LINK
As Cartsen suggested, you shud have administrative permission to unlock the account. U can do it from the AD MMC console.
Code to unlock using C# (System.Directoryservices namespace):
private void btnDisableUser_Click(object sender, System.EventArgs e)
string strUserName = "InsertUserNameHere";
DirectoryEntry usr = new DirectoryEntry("LDAP://dc=InsertDomainHere, dc=COM");
DirectorySearcher searcher = new DirectorySearcher(usr);
searcher.Filter = "(SAMAccountName=" + strUserName + ")";
searcher.CacheResults = false;
SearchResult result = searcher.FindOne();
usr = result.GetDirectoryEntry();
usr.Properties["LockOutTime"].Value = 0x0000;