Reseting a users password via Active Directory using Visual Basic 2010..
Hi Guys im writing a little app to enable authorised staff to reset student passwords but having a few issues. . I am no expert and am now stuck!
The following code does not seem to error but also does not reset the password!
_________________________
Private Sub bt_pwd_reset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_pwd_reset.Click
tb_newpwd1.Text = GenPassword.ToString
Try
Dim username As String = TUserName.Text
Dim de As DirectoryEntry = New DirectoryEntry()
de.Path = "LDAP://10.33.0.25/OU=Staff_Users;dc=domain,dc=domain,dc=internal"
Dim deSearch As DirectorySearcher = New DirectorySearcher(de)
deSearch.SearchRoot = de
deSearch.Filter = ("(sAMAccountName=" & username & ")")
Dim results As SearchResultCollection = deSearch.FindAll()
If results.Count = 0 Then
message.Text = "Can not locate user name: " & username
message.Visible = True
Exit Sub
End If
With de
.InvokeSet("serPassword", "Password123")
' .Invoke("SetPassword", Password123)
.CommitChanges()
End With
de.Close()
Catch ex As Exception
message.Text = ex.ToString
End Try
lb_bigpwd.Text = tb_newpwd1.Text
End Sub
Bookmarks