binding to active directory to change password
This is my code. I keep getting an error message. any advice.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Try
Dim entry As DirectoryEntry = New DirectoryEntry("ldap://ou=windows XP, OU=Managed Computers, DC=puc, DC=state, DC=oh, DC=us", Username.Text, Password.Text, AuthenticationTypes.Secure)
Dim Dsearch As DirectorySearcher = New DirectorySearcher(entry)
'Dim entry As DirectoryEntry = New DirectoryEntry '("ldap://ou=windows XP, OU=Managed Computers, DC=puc, DC=state, DC=oh, DC=us", "username", "password")
Dsearch.Filter = "(&(objectClass=user)(l=" + Name + "))"
Dim bindCheck As Object = entry.NativeObject
entry.NativeObject.changepassword("oldpassword", "newpassword")
entry.Invoke("setPassword", New Object() {"oldpassword", "newpassword"})
entry.CommitChanges()
'Finally
'If Not entry Is Nothing Then entry.Dispose()
'End Try
Console.Write("successful")
Console.Write("invalid")
End Sub