benperiton
I’m attempting to integrate some AD stuff with my app, but I’m stuck on how to use the GUID that is returned with Ecto.
From exldap, I get this back:
'objectGUID' => [
[219, 12, 193, 79, 151, 81, 153, 75, 128, 88, 23, 96, 59, 10, 33, 175]
]
which is fine, except if I try and load it with Ecto I get the wrong UUID back:
[219, 12, 193, 79, 151, 81, 153, 75, 128, 88, 23, 96, 59, 10, 33, 175]
|> :binary.list_to_bin
|> Ecto.UUID.load
{:ok, "db0cc14f-9751-994b-8058-17603b0a21af"}
Expected: 4FC10CDB-5197-4B99-8058-17603B0A21AF
Actual: DB0CC14F-9751-994B-8058-17603B0A21AF
I’m sure there’ something obvious that I’m overlooking!
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
axelson
This was a cool little problem!
First step, find the “correct” format of the expected UUID “4FC10CDB-5197-4B99-8058-17603B0A21AF”
Hmmm, some of those numbers look similar. Let’s look at them side by side (aligned by comma):
In chunks:
So for some reason (someone else may understand the reason) the first 4 numbers are reversed, then the next two, and the next two again, but all the rest after that match (which is why “8058-17603B0A21AF” is decoded correctly).
So you can write a function to convert as follows:
Which can then be used for the desired output:
benperiton
Thank you!!
I spent so long looking at it, I couldn’t see that the first 3 parts were reversed!
Which with some googling leads to:
So I think that explains the ordering of the first 3 parts.
Thankyou again!
axelson
Awesome, I’m glad it’s helpful!
benperiton
So that has now lead me to this: (Thanks to this post on mixed endian binaries - Pete Corey - Building Mixed Endian Binaries with Elixir)
And then a nice little function to swap:
axelson
Ah, very nice!
sribe
And all this means that somewhere, they’re getting converted to/from integers by code which is not aware of the different byte-ordering between variants. My guess is Ecto, might be worth a bug report…
benperiton
Yea, I was wondering if it was Exldap (which calls out to eldap) as that is where the list came from, or if it is Ecto as it is not making sure that the endians are correct.
I’ll have a play in a bit with some other UUID libs and see if I can come up with where the issue is
Edit:
Thinking about it, that is how it is stored in AD, so it’s not really anything to do with Exldap, so yea would seem more likely that Ecto is not checking endiness.
OvermindDL1
‘How’ would it check that?
sribe
I would hope there would be bits specifying the variant at a fixed location, octet-wise, and they would include that. But of course this is MS we’re talking about, so who knows. (A few minutes with google produced a lot of discussions but no real answer.)
benperiton
So for completeness, this is the issue I raised: Endiness check for UUIDs · Issue #2660 · elixir-ecto/ecto · GitHub
Basic gist is that there is a difference between a UUID and a GUID (I always assumed they were the same) - that difference being the endiness, so it’s not really down to Ecto.
I’m just going to create a new type for it and use that instead - I’ll update this post with it when I get back around to looking at that app