I am trying to accomplish this task: change my own password in ActiveDirectory using a Go program and the gopkg.in/ldap.v2
package.
Unfortunately my Modify request ends with error 65 with the following description:
"0000207D: UpdErr: DSID-031517D5, problem 6002 (OBJ_CLASS_VIOLATION), data 589914"
The code is the following:
var l *ldap.Conn
var err error
l, err = ldap.Dial(`tcp`, fmt.Sprintf(`%s:%d`, domain, 389))
if err != nil {
return false, err
}
defer l.Close()
err = l.Bind(logonUserName, currentPassword)
if err != nil {
return false, err
}
utf16 := unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM)
encoded, err := utf16.NewEncoder().String(`"`+newPassword+`"`)
baseDN := "DC=contoso,DC=com"
modifyReq := ldap.NewModifyRequest(baseDN)
modifyReq.Replace("unicodePwd", []string{encoded})
err = l.Modify(modifyReq)
if err != nil {
return false, err
}
I have found some info on this thread: https://stackoverflow.com/a/37355844/1268795
What am I missing?