diff options
author | David Boreham <dboreham@redhat.com> | 2005-05-06 03:27:20 +0000 |
---|---|---|
committer | David Boreham <dboreham@redhat.com> | 2005-05-06 03:27:20 +0000 |
commit | 2930910e6503a99d220454203a10f01e6503e31b (patch) | |
tree | 0b2f5ac562be6aa93e736cc6061d18b6e216071a /ldap/servers/plugins/replication/windows_protocol_util.c | |
parent | 5f5d8a6082eca33b2ca3cce69d66c0f868221034 (diff) | |
download | ds-2930910e6503a99d220454203a10f01e6503e31b.tar.gz ds-2930910e6503a99d220454203a10f01e6503e31b.tar.xz ds-2930910e6503a99d220454203a10f01e6503e31b.zip |
Fix for #157020: convert unicode password to little-endian byte order
Diffstat (limited to 'ldap/servers/plugins/replication/windows_protocol_util.c')
-rw-r--r-- | ldap/servers/plugins/replication/windows_protocol_util.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c index 4aa94020..562a7c65 100644 --- a/ldap/servers/plugins/replication/windows_protocol_util.c +++ b/ldap/servers/plugins/replication/windows_protocol_util.c @@ -700,6 +700,19 @@ windows_release_replica(Private_Repl_Protocol *prp) } +static void +to_little_endian_double_bytes(UChar *unicode_password, int32_t unicode_password_length) +{ + int32_t i = 0; + for (i = 0 ; i < unicode_password_length; i++) + { + UChar c = unicode_password[i]; + char *byte_ptr = (char*)&(unicode_password[i]); + byte_ptr[0] = (char)(c & 0xff); + byte_ptr[1] = (char)(c >> 8); + } +} + /* this entry had a password, handle it seperately */ /* http://support.microsoft.com/?kbid=269190 */ static int @@ -729,6 +742,9 @@ send_password_modify(Slapi_DN *sdn, char *password, Private_Repl_Protocol *prp) error = U_ZERO_ERROR; u_strFromUTF8(unicode_password, buffer_size, &unicode_password_length, quoted_password, strlen(quoted_password), &error); + /* As an extra special twist, we need to send the unicode in little-endian order for AD to be happy */ + to_little_endian_double_bytes(unicode_password, unicode_password_length); + bv.bv_len = unicode_password_length * sizeof(UChar); bv.bv_val = (char*)unicode_password; |