1

I looked up a distribution list's objectGUID property in ADUC. However, despite copy/pasting the data directly, my LDAP query wouldn't work. I queried the same object with different criteria and printed out the fetched GUID and I noticed parts of it are in different order. Here they are side by side (tabbed apart for readability).

34E16D90    BAD1    4ED7    B51A    88C5C4CE7FA2  
 ^----.      \       /
906DE134    D1BA    D74E    B51A    88C5C4CE7FA2

As you can see, for each group the pairs themselves are the same, but the order the pairs are arranged are backwards... but for just the first three groups. Other Active Directory tools show the GUID the same as ADUC. I queried the out-of-order GUID and it works. Is there an explanation for this?

Marc B
  • 356,200
  • 43
  • 426
  • 500
Gary
  • 13,303
  • 18
  • 49
  • 71
  • `3 < 9`, so the first guid as a whole comes first, regardless of the value of the sub sections. – Marc B Jul 18 '16 at 21:43
  • @MarcB Sorry, maybe I was unclear. They both are the GUID for the same object. The first is how it displays in Active Directory, the second is how it shows when I query the same object in PHP... Unless I'm misunderstanding what you're telling me. – Gary Jul 18 '16 at 21:46
  • oh. I see. word-wise reversal in there. I was comparing d1ba->4ed7 and what not. – Marc B Jul 18 '16 at 21:48
  • I can see how it reads that way. I'm trying to find a better way to word the question. – Gary Jul 18 '16 at 21:52
  • Possible duplicate question (\w Answer): http://stackoverflow.com/questions/7810602/sql-server-guid-sort-algorithm-why – Wesley Abbenhuis Jul 18 '16 at 21:53
  • 1
    a little ascii art never hurts. – Marc B Jul 18 '16 at 21:54
  • @DiceXQ I'll have to look at that answer more when I get home, but wouldn't the endianness just dictate the order of each byte pair and not the order that each pair appears in the group? – Gary Jul 18 '16 at 21:58
  • The link implies that only the last 6 bytes are being used by SQL Server to sort GUIDS. Therefor the PHP GUID sorting does not equals the SQLGuid sorting (2 different algoritmes) as far as I can find online :) – Wesley Abbenhuis Jul 18 '16 at 22:16
  • Can you reproduce that behaviour with a console-tool (like ldapsearch) or another third tool (like jXplorer)? That would be interesting whether it's a PHP-issue (which should be fixed then, please open a bug-report on http://bugs.php.net) or an issue with he protocol itself. – heiglandreas Jul 19 '16 at 06:14
  • @DiceXQ As far as I read it the link you gave handles sorting of UUIDs. But here it's about displaying UUIDs and even though UUIDs might be stored internally in different formats (little/big-endian) they should always be the same when output (https://en.wikipedia.org/wiki/Globally_unique_identifier#Binary_encoding). So that might be an issue with the ADUC that it shows the UUID in the internal storage format. – heiglandreas Jul 19 '16 at 06:25

1 Answers1

2

GUID format is fun. There is a mix endian model that is the 'standard'. You can parse the Binary data in many different ways. How any particular app represents the GUID as non-Binary is up to the app.

Wikipedia on GUID is shockingly interesting.

geoffc
  • 4,030
  • 7
  • 44
  • 51
  • Two quotes of note from your source: The first seems to explain the difference in why the two read them, "**Microsoft defines a format which... differs from the UUID standard only in the byte order of the first 3 fields**" and why the first three *fields* (which I mistakenly called groups) behave differently, "**For the first three fields, the most significant digit is on the left. The last two fields are treated as eight separate bytes...**" – Gary Jul 19 '16 at 20:29