从ADODB.Recordset访问[Object Array of Byte] objectGUID值用于Active Directory查询

问题描述:

我正在使用JavaScript和ActiveX来查询Active Directory。一切都很好,但我不能为我的生活弄清楚如何访问类型为[object Array of Byte]的对象的值。我知道值在那里,因为我可以在IE调试器窗口中看到它们。从ADODB.Recordset访问[Object Array of Byte] objectGUID值用于Active Directory查询

我使用的代码:

<!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> 

表示数据的IE的调试器窗口的屏幕快照是存在的。我只是无法弄清楚如何访问它...

enter image description here

我不是一个聪明的人。发布此消息后5分钟,我能够找出答案。

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

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