Convert binary to UUID from LDAP

Steven Schveighoffer schveiguy at gmail.com
Tue Mar 28 13:30:13 UTC 2023


On 3/28/23 1:05 AM, Alexander Zhirov wrote:
> On Tuesday, 28 March 2023 at 00:51:43 UTC, Steven Schveighoffer wrote:
>> `auto uuid = UUID(*cast(ubyte[16]*)youruuiddata.ptr);` (added quotes here)
> 
> ```d
> ubyte[] arr = cast(ubyte[])value.attributes["objectGUID"][0].dup;
> writeln(UUID(cast(ubyte[16])arr.ptr));
> ```
> 
> `Error: cannot cast expression 'cast(ubyte*)arr' of type 'ubyte*' to 
> 'ubyte[16]'`
> 
> No, it's not possible to transform. The array is initially 
> `immutable(char[])`.
> 

Apologies, I quoted my original above to suppress the markdown 
formatting. Here it is again with syntax highlighting.

```d
auto uuid = UUID(*cast(ubyte[16]*)youruuiddata.ptr);
```

That should work. I sometimes forget that my newsreader adds the 
markdown tag, even though it looks good on my end.

-Steve


More information about the Digitalmars-d-learn mailing list