Hello
I'm talking to active directory through Net::LDAP, and I want to extract user GUIDs in a readable form.
If I query a user, I don't get a GUID field, but instead a nasty contraption called objectGUID. This, I believe is supposed to be a 128bit binary field. In a debugger, it looks like this:
'objectGUID' => 'Q?Ot?qM?r/?'I have a GuidToString routine, filthily stolen from the internets, which I have posted below. In a nutshell, I'm looking for a hex string in the form: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
The below code gives me that, but something is just not right, especially as most of the strings I get back have > 8 0's on the end in most cases.
Has anybody played with this before? Afaik, guid is the only thing that can never change on a users ad account, and I need to record these for a intranet based web app.
Any help much appreciated...
Here's that routine...
sub GuidToString { return sprintf "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%0 +2X", unpack("I", $_[0]), unpack("S", substr($_[0], 4, 2)), unpack("S", substr($_[0], 6, 2)), unpack("C", substr($_[0], 8, 1)), unpack("C", substr($_[0], 9, 1)), unpack("C", substr($_[0], 10, 1)), unpack("C", substr($_[0], 11, 1)), unpack("C", substr($_[0], 12, 1)), unpack("C", substr($_[0], 13, 1)), unpack("C", substr($_[0], 14, 1)), unpack("C", substr($_[0], 15, 1)); }
In reply to Net::LDAP GUID... by muffinman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |