Wrote a variation of this for different purposes over the past few months. You can get creative and put it in a web service or within your web application. You would also want to send a lot of the initial variables in through ByVal when you call the Function or Method.
Dim user As String = "yourdomain/userToUnlock" Dim pwd As String = "userToUnlockPW" Dim de As DirectoryEntry = Nothing Dim ds As DirectorySearcher = Nothing Dim url As String = "LDAP://111.11.111.1111/dc=yourdomain,dc=com" de = New DirectoryEntry(url) de.Username = "yourdomain/authorizedADuser" de.Password = "authorizedADuserPW" de.AuthenticationType = AuthenticationTypes.Secure Or AuthenticationTypes.ServerBind Or AuthenticationTypes.Sealing ds = New DirectorySearcher(de) ds.SearchRoot = de ds.Filter = String.Format("(&(objectClass=user)(objectCategory=person)(sAMAccountName={0}))", user) ds.PropertiesToLoad.Add("userAccountControl") Dim result As SearchResult = ds.FindOne If Not result Is Nothing Then de = result.GetDirectoryEntry de.RefreshCache() de.Properties("LockOutTime").Value = 0 de.Properties("userAccountControl").Value = &H200 de.Invoke("SetOption", New Object() {6, 6}) de.Invoke("SetOption", New Object() {7, 1}) de.Invoke("SetPassword", New Object() {pwd}) de.CommitChanges() de.Close() End If