Delphi: How can I change the password for a MS Active Directory account?
In order to change a MS AD account password using LDAP you will need to convert the unicode password to a RawByteString.
For Example:
ipsLDAPS1->AttrCount = 1;
ipsLDAPS1->AttrType[0] = "unicodePwd";
UnicodeString uStr = L"\"Mynewpassword1\"";
ipsLDAPS1->AttrValueB[0] = RawByteString((char*)uStr.data(), uStr.Length()*2);
ipsLDAPS1->AttrModOp[0] = (TipsLDAPSAttrModOps)amoReplace;
ipsLDAPS1->Modify();
Note that when converting a unicode password to a RawByteString the AttrValuB property should be used.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.