gpt4 book ai didi

coldfusion - 如何在 Coldfusion 中将 Active Directory objectGUID 转换为 UUID

转载 作者:行者123 更新时间:2023-12-02 03:34:20 25 4
gpt4 key购买 nike

我有一个返回 objectGUID 的 CFLDAP 查询。如何在 ColdFusion 中将其转换为 8-4-4-4-12 模式的有效 UUID 字符串?

我已经指定了 returnAsBinary="ObjectGUID",但是 toString(getLDAP.ObjectGUID) 没有返回所需的结果。

更新:

我尝试了 binaryEncode():

<cfset guid = binaryencode(getLDAP.objectguid,"HEX")> 

返回:

18E0CE3388B79C4EA4D73894AE8CD8F6

但我期待这个(由另一个我看不到他们的转换步骤的过程提取和提供)。

3cee018-b788-4e9c-a4d7-3894ae8cd8f6 

嗯……虽然不匹配,但后半段是一样的。 a4d7-3894ae8cd8f6

最佳答案

hummm... the last half is the same

很有趣。来自 this thread 的链接解释为什么。显然,它是 more involved than just converting the binary into hex, in one shot :

  1. First, know the sequence of the byte index that forms the Dashed String: [3] [2] [1] [0] - [5] [4] - [7] [6] - [8] [9] - [10] [11] [12] [13] [14] [15]
  2. Next, apply bit masking to each and every single byte value accessed in the array.
  3. Follow by converting to the Hex representation of the value.
  4. Just make sure that the Hex value is a double digit value, meaning instead of "A", it should be "0A"

由于CF的数组是从1开始的,所以只需要在位置上加上+1。这会以正确的顺序构建解码后的字符串(没有破折号,您可以使用字符串函数轻松添加破折号)。

 // Get GUID binary
bin = yourQuery.objectGUID[rowNumber];
// Extract bytes in this sequence
order = [4,3,2,1, 6,5, 8,7, 9,10,11,12,13,14,15,16];
// Stores converted bytes
hex = [];

for (pos in order) {
// Apply mask to current byte and convert to hext
arrayAppend(hex, formatBaseN(BitAnd(bin[pos], 255), 16));
}

writeOutput("Hex string = "& arrayToList(hex, ""));

关于coldfusion - 如何在 Coldfusion 中将 Active Directory objectGUID 转换为 UUID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50766504/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com