S
smirks
Hi,
I am retrieving some information from a Microsoft Active Directory
Server via Java's JNDI API.
In particular, I'm trying to get an attribute called 'objectSID', which
is of type Octet-String on the active directory.
My problem is that when trying to convert the returned value to a hex
representation, some of the bytes are incorrectly converted.
Let me explain further:
After performing a certain query on the ldap server, I read the
returned objectSID attribute by calling:
String value = (String) attrib.get();
....where attrib is the attribute containing the retrieved objectSID.
While debugging, I do a simple print out of the above string (using a
simple System.out.println(value)), to get the following byte
representation:
u?uT?`C
2?
I use Apache's commons-codec API to convert the above string to a Hex
represenation as follows...
String hex = new String( Hex.encodeHex(value.getBytes()) );
.... and when I print it out, I get:
010500000000000515000000753f75540f3f601d43170a323f040000
However, the correct hex value as stored on the active directory server
when performing a certain query, should be as follows:
01050000000000051500000075b975540ff8601d43170a32e4040000
This is close, but not quite the correct value.
In fact, when I try to reverse the correct hex value to the byte
representation, I get:
u¹uTø`C
2ä
.... which is therefore the actual value that I should be getting when
reading the naming attribute in the first place and casting it to a
String, right?
I believe the problem has to do with character encoding, but I don't
know how to proceed from here. I have tried various character sets when
converting 'value' to a byte array above, but to no avail.
Any help will be greatly appreciated.
Regards,
Clyde
I am retrieving some information from a Microsoft Active Directory
Server via Java's JNDI API.
In particular, I'm trying to get an attribute called 'objectSID', which
is of type Octet-String on the active directory.
My problem is that when trying to convert the returned value to a hex
representation, some of the bytes are incorrectly converted.
Let me explain further:
After performing a certain query on the ldap server, I read the
returned objectSID attribute by calling:
String value = (String) attrib.get();
....where attrib is the attribute containing the retrieved objectSID.
While debugging, I do a simple print out of the above string (using a
simple System.out.println(value)), to get the following byte
representation:
u?uT?`C
2?
I use Apache's commons-codec API to convert the above string to a Hex
represenation as follows...
String hex = new String( Hex.encodeHex(value.getBytes()) );
.... and when I print it out, I get:
010500000000000515000000753f75540f3f601d43170a323f040000
However, the correct hex value as stored on the active directory server
when performing a certain query, should be as follows:
01050000000000051500000075b975540ff8601d43170a32e4040000
This is close, but not quite the correct value.
In fact, when I try to reverse the correct hex value to the byte
representation, I get:
u¹uTø`C
2ä
.... which is therefore the actual value that I should be getting when
reading the naming attribute in the first place and casting it to a
String, right?
I believe the problem has to do with character encoding, but I don't
know how to proceed from here. I have tried various character sets when
converting 'value' to a byte array above, but to no avail.
Any help will be greatly appreciated.
Regards,
Clyde