carloselectro

Cannot get OS version from AD with UDF?

19 posts in this topic

#1 ·  Posted

Hi,

I'm trying to get the computer 's OS version from the Active Directory with the AD UDF but I cannot get it to work.

The following code work so I know my syntax is alright:

 

$aResult = _AD_GetObjectAttribute("my_pc_name$", "name")
ConsoleWrite("My attribute:" & $aResult)

But I cannot get the OS version attribute even though it does exist in the AD:

 

$aResult = _AD_GetObjectAttribute("my_pc_name$", "operatingSystem")
ConsoleWrite("My attribute:" & $aResult)

I get the following errors:

Local $sResult = $oObject.Get($sAttribute)
Local $sResult = $oObject^ ERROR

Am I supposed to be able to get any existing attribute from the AD?

 

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I would hope he is running a Windows Server build more recent than Windows 2000 anyway :sweating:.

Edited by anthonyjr2

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#4 ·  Posted

The following works fine for me Windows 10 Enterprise x64, AD UDF Version 1.4.7.0

#include <AD.au3>
_AD_Open()
$aResult = _AD_GetObjectAttribute(@ComputerName & "$", "operatingSystem")
_AD_Close()
ConsoleWrite("My attribute for " & @ComputerName & ":" & $aResult & @CRLF)

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

I am using Server 2012. My UDF version is 1.4.8.0. I wonder why it works for you.

Share this post


Link to post
Share on other sites

#6 ·  Posted

Not sure our servers are a mix of Win 2008 R2, Win 2012 R2 and Win 2016, looking at the error it looks as though its lost the connection to AD, even if I add an unknown computer name it doesn't throw any errors, normally I would then use the @error to find out the issue.  Looking at the _AD_GetObjectAttribute function (Ctrl+J) it must be failing here:

Local $oObject = __AD_ObjGet($sLDAPEntry) ; Retrieve the COM Object for the object

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

Can you please post the full error message?

Can you please post the complete script you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted

My problem seems to be related to the way I call the _AD_Open function:

This works

$iResult = _AD_Open()

This does not:

$iResult = _AD_Open("", "", "", "dti-dc3:3268") ; LDAP Catalog INfo


 

Share this post


Link to post
Share on other sites

#9 ·  Posted

What is the  value of @error after _AD_Open?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

There's no error after executing  _AD_Open , it return 0 in both cases.

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

Can you please pass the full name as parameter 4? Means "dti-dc3.company.com:3268" (example) instead of "dti-dc3:3268".


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

I just did and I get the same error:

Error:0"D:\PortableApps\Autoit Portable\Include_Custom\AD\AD.au3" (641) : ==> The requested action with this object has failed.:
Local $sResult = $oObject.Get($sAttribute)
Local $sResult = $oObject^ ERROR

Share this post


Link to post
Share on other sites

#13 ·  Posted

Which version of AutoIt do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#14 ·  Posted

Version 3.3.14.2

Share this post


Link to post
Share on other sites

#15 ·  Posted

Will check as soon as I return to my office.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#16 ·  Posted

Sure, I can make it work for now by using _AD_OPEN() only but I'll be available to do do more testing.

 

Share this post


Link to post
Share on other sites

#17 ·  Posted

The problem you face  is caused by the fact that not all properties are propagated to the Global Catalog.
Here you find a list of all available properties: http://www.selfadsi.org/global-catalog-attributes.htm


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#18 ·  Posted

Thank you for the followup.

 

Share this post


Link to post
Share on other sites

#19 ·  Posted

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now