Endianness of Active Directory objectUUID Attributes in Java / Apache Directory Studio -
i connecting active directory server java. add property:
env.put("java.naming.ldap.attributes.binary", "objectguid");
and read objecuuid this:
attribute = result.getattributes().get("objectuuid"); byte[] b = (byte[])a.get();
and format this:
string id = hex. encodehexstring(b). replaceall( "(.{8})(.{4})(.{4})(.{4})(.{12})", "$1-$2-$3-$4-$5" ) );
the result nicely format uuid. when want find entry uuid, remove dashes:
id = id.replaceall("[^a-za-z0-9]+", "");
and insert backslashes:
id = id.replaceall("([a-za-z0-9]{2,2})", "\\\\$1");
this works nicely. having problem fact apache directory studio shows (for example) user's uuid as:
8e591e3a-35ab-45cc-8dca-c5e451adc975
wheras code shows uuid of same entry as:
3a1e598e-ab35-cc45-8dca-c5e451adc975
as can see, high- , low order bytes swapped left 8 bytes, identical on right side. why that? seems weird ...
.rm
if here:
https://en.wikipedia.org/wiki/universally_unique_identifier
name length (bytes) length (hex digits) contents time_low 4 8 integer giving low 32 bits of time time_mid 2 4 integer giving middle 16 bits of time time_hi_and_version 2 4 4-bit "version" in significant bits, followed high 12 bits of time clock_seq_hi_and_res clock_seq_low 2 4 1-3 bit "variant" in significant bits, followed 13-15 bit clock sequence node 6 12 48-bit node id
you can see first 3 segments integers/shorts related "time" data , therefore have endianness, whereas other sections binary data , not.
Comments
Post a Comment