Convert AD's objectGUID to string

One Star

Convert AD's objectGUID to string

Hi!
I need to convert an Active Directory's objectGUID (which is binary data) to a string (like "9698dc61-89f0-42b9-90c8-b54aee97d4ff").
How can I do it?
Seventeen Stars

Re: Convert AD's objectGUID to string

Create a routine and add this method to it:
	
public static String toHexString(byte[] bin) {
StringBuilder sb = new StringBuilder();
for (byte b : bin) {
sb.append(Integer.toHexString(b));
}
return sb.toString();
}
One Star

Re: Convert AD's objectGUID to string

Thanks, jlolling!
The solution produce output like "61ffffffdcffffff98ffffff96fffffff0ffffff89ffffffb942ffffff90ffffffc8ffffffb54affffffeeffffff97ffffffd4ffffffff" (instead of 9698dc61-89f0-42b9-90c8-b54aee97d4ff), but you have pointed me to right way, so I'll try to use existing java examples to generate required string.
If anybody have the complete solution for generation GUID in AD style, post it here, please.
Seventeen Stars

Re: Convert AD's objectGUID to string

Yes, the values you get are 4-byte digits. My code was made for 1-byte digits.