从 ADODB.Recordset 访问 [object Array of Byte] objectGUID 值以进行 Active Directory 查询

access [object Array of Byte] objectGUID value from ADODB.Recordset for an Active Directory query

我正在使用 JavaScript 和 ActiveX 来查询 Active Directory。一切都很好,但我终生无法弄清楚如何访问 [object Array of Byte] 类型对象的值。我知道这些值在那里,因为我可以在 IE 调试器中看到它们 window.

我使用的代码:

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript">
            var recordSet;
            function doIt()
            {
                var ADConnection = new ActiveXObject("ADODB.connection");
                var ADCommand = new ActiveXObject("ADODB.Command");
                ADConnection.ConnectionTimeout = 600;
                ADConnection.Open("Data Source=Active Directory Provider;Provider=ADsDSOObject");
                ADCommand.ActiveConnection = ADConnection;
                ADCommand.Properties("Page Size") = 10000;
                ADCommand.Properties("Searchscope") = 2;
                ADCommand.Properties("Timeout") = 600;
                ADCommand.Properties("Cache Results") = false;
                ADCommand.Properties("Chase Referrals") = 96;
                ADCommand.CommandTimeout = 600;

                ADCommand.CommandText = "<GC://DC=company,DC=com>;(&(objectCategory=person)(objectClass=user)(anr=imthenachoman));distinguishedName,objectGUID;subtree";

                var recordSet = ADCommand.Execute;

                var distinguishedName = recordSet.Fields("distinguishedName").value;
                var objectGUID = recordSet.Fields("objectGUID");

                // this works
                alert(distinguishedName);

                // according to IEs debugger, objectGUID is a of type [object Field]
                // objectGUID.value is [object Array of Byte] but I cannot figue out how to access each value in the array                

                recordSet.Close();
            }
        </script>
    </head>
    <body>
        <a href="#" onclick="doIt(); return false;">do it</a>
    </body>
</html>

显示数据的 IEs 调试器屏幕截图 window。我只是不知道如何访问它...

我不是聪明人。发布后 5 分钟,我就能从字面上找出答案。

objectGUID = (new VBArray(objectGUID.value)).toArray();

这会将 [object Array of Byte] 转换为 JavaScript 友好的整数数组。