Jump to content
Sign in to follow this  
supersonic

Avoid AD query failure if computer is not in AD

Recommended Posts

supersonic

Hi!

I'm "messing" around with the UDF "adfunctions.au3".

When running a script using this UDF on a non-AD computer,

I get the following error message (- even when no AD functions are called):

C:\TEMP\_\AUTOIT\Include\ADFunctions\ADFunctions.au3 (104) : ==> Variable must be of type "Object".:

Global $strDNSDomain = $objRootDSE.Get("defaultNamingContext")

Global $strDNSDomain = $objRootDSE^ ERROR

How could I avoid the error and keep the script running?

Setting an error handler couldn't this (yet).

Any Ideas?

Greets,

-supersonic.

Share this post


Link to post
Share on other sites
PsaltyDS

Hi!

I'm "messing" around with the UDF "adfunctions.au3".

When running a script using this UDF on a non-AD computer,

I get the following error message (- even when no AD functions are called):

C:\TEMP\_\AUTOIT\Include\ADFunctions\ADFunctions.au3 (104) : ==> Variable must be of type "Object".:

Global $strDNSDomain = $objRootDSE.Get("defaultNamingContext")

Global $strDNSDomain = $objRootDSE^ ERROR

How could I avoid the error and keep the script running?

Setting an error handler couldn't this (yet).

Any Ideas?

Greets,

-supersonic.

That UDF unconditionally initializes some domain related global variables by running some COM functions at run time without any of its UDF functions being called yet. I don't care for that and believe that makes it a poorly behaved UDF, but maybe that's just me.

You need a COM error handler to handle these errors gracefully.

Another option is to put that portion of the initialization in a function of its own, like _AD_Init(), and only run that to initialize those globals when you expect to be on a domain.

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
supersonic

Thank you for the answer.

I added:

If IsObj($oRootDSE) = 0 Then Return ""

... this helped me out.

That UDF unconditionally initializes some domain related global variables by running some COM functions at run time without any of its UDF functions being called yet. I don't care for that and believe that makes it a poorly behaved UDF, but maybe that's just me.

You need a COM error handler to handle these errors gracefully.

Another option is to put that portion of the initialization in a function of its own, like _AD_Init(), and only run that to initialize those globals when you expect to be on a domain.

^_^

Edited by supersonic

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.