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. 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch