2016-03-04 94 views
0

我正在使用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

回答

0

我不是一個聰明的人。發佈此消息後5分鐘,我能夠找出答案。

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

這會將[object Array of Byte]轉換爲JavaScript友好的整數數組。