I am creating a windows form app that will allow our IT admins to reset passwords on an old domain we only use sparingly. Throughout my searches I have come across multiple methods of scripting this, but each comes back with some type of error. My current code looks like:
This results in a login failure to do an unknown username or password. When I added:
I get an error stating referral was returned from the server. What it looks like is with the Username and Password set it is making the connection but my Invoke is failing (maybe?)?
Can anyone who has more experience with VB.net and AD/LDAP be able to offer some assistance? Maybe even a clarification on what the "referral" error is referring to - pardon the pun.
VB.NET:
Private Sub ChangePassword(ByVal username As String, ByVal oldpw As String, ByVal newpw As String)
Try
Dim de As New DirectoryEntry()
de.Path = "LDAP://<ip>/CN=Users;DC=microsoft.com" ''information changed
de.AuthenticationType = AuthenticationTypes.Secure
Dim ret As Object = de.Invoke("SetPassword", newpw)
de.CommitChanges()
de.Close()
Catch ex As Exception
MsgBox("Error." & vbNewLine & ex.ToString())
End Try
End Sub
This results in a login failure to do an unknown username or password. When I added:
VB.NET:
de.Username = "microsoft\Bill"
de.Password = "Gates"
I get an error stating referral was returned from the server. What it looks like is with the Username and Password set it is making the connection but my Invoke is failing (maybe?)?
Can anyone who has more experience with VB.net and AD/LDAP be able to offer some assistance? Maybe even a clarification on what the "referral" error is referring to - pardon the pun.
Last edited: