unicodePwd attribute

J

Jeannie

I have tried to generate the unicodePwd by double quoting
and then base64 encoding it. I have tried to use the tool
http://www.opinionatedgeek.com/DotNet/Tools/Base64Encode/De
fault.aspx, using perl and java to encode it.

However, I am not able to import it using LDIFDE, it
always complaint that "The unicodePwd attribute value must
be enclosed in double quotes. However, I am successful
using the sample in article Q263991 as follows:

The following sample Ldif file (chPwd.ldif) changes a
password to newPassword:
dn: CN=TestUser,DC=testdomain,DC=com
changetype: modify
replace: unicodePwd
unicodePwd::IgBuAGUAdwBQAGEAcwBzAHcAbwByAGQAIgA=
-

I am not able to get the above same encoded string if I
tried to encode "newPassword" myself. I search all other
postings and tried all the encoded password other people
used without any success.

Do anybody know how could I generate the unicodePwd
correctly?

Thanks a lot.
 
M

Matjaz Ladava [MVP]

You can not use LDIFDE to set password, only to change it (modify) .
 
G

Guest

I have figured it out. Here is the code:

String password = "internal";
String quotePassword = "\"" + password + "\"";
try{
byte[] unicodeBytes = quotePassword.getBytes
("Unicode");
byte[] strippedUnicodeBytes = new byte
[unicodeBytes.length - 2];
for (int i = 0; i < unicodeBytes.length -
2; i++) {
strippedUnicodeBytes = unicodeBytes
[i+2];
}

System.out.println
("strippedUnicodeBytes="+strippedUnicodeBytes);
System.out.println("Base64 String
is "+Base64.encode(strippedUnicodeBytes));
}catch(java.io.UnsupportedEncodingException e){
e.printStackTrace();

}

I use the Base64 class from soap.jar, you can use other
one I guess.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top