What is the problem over here? I'm prioviding old, and new password. But somehow getting this problem while changing password.
I'm using LDAP V3 As request I'm using PasswordModifyRequest with oldPassword, newPassword and UserDN as domainLogin. Somehow always getting this issue. Is there a problem with my code or there should some specific setting on AD so my method can work?
baseDN := "dc=" + strings.Replace(ldap.Domain, ".", ",dc=", -1)
pass := ldap2.PasswordModifyRequest{
UserIdentity: baseDN ,
OldPassword: OldPassword,
NewPassword: NewPassword,
}
// Send the ModifyRequest to the server
res, err := li.Conn.PasswordModify(&pass)
if err != nil {
fmt.Printf("Error changing the password: %s\n", err)
return err
}
Found a solution. I decided to use Modify instead of ModifyPassword. The problem itself was about server properties and the version of AD. In my case, I provided more specific DN attributes and Control to use Modify.
controlTypes, err := getSupportedControl(li.Conn)
if err != nil {
return err
}
control := []ldap2.Control{}
for _, oid := range controlTypes {
if oid == controlTypeLdapServerPolicyHints || oid == controlTypeLdapServerPolicyHintsDeprecated {
control = append(control, &ldapControlServerPolicyHints{oid: oid})
break
}
}
err = li.Conn.Modify(passReqA)
if err != nil {
return err
}