How to Unlock a Domain Account in Active Directory utilizing C# .Net - (note: you must have Domain Admin privledges to execute this code successfully and you must import the 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;
usr.CommitChanges();
}
Recent Comments
5 days 20 hours ago
6 days 1 hour ago
5 weeks 6 days ago
13 weeks 6 days ago
14 weeks 1 hour ago
16 weeks 1 day ago
18 weeks 1 day ago
1 year 23 weeks ago
1 year 23 weeks ago
1 year 25 weeks ago