IanN1990

AD - Check if domain is offline / unavailable or connection time out [Solved]

9 posts in this topic

#1 ·  Posted (edited)

Hi,

I have a issue at the moment that some of my domain controller go down and that causes big delays in my script.

Is there any way of checking a domains status / availability before attempting to connect or if not is there any way to set a time-out when opening a connection (similar to _ieLoadwait timout)?

Ian

Edited by IanN1990

Share this post


Link to post
Share on other sites



_AD_ListDomainControllers returns a list of all DCs. Do a ping and you will - at least - know if the server itself is up.


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

As your the creator of the most useful AD UDF

I will close this as solved :) 

Share this post


Link to post
Share on other sites

Thanks :)


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

#5 ·  Posted (edited)

As your the creator, whats your honest view on this code.

#include "ad.au3"

   ConsoleWrite(@Crlf & CheckFastestADConnection())

   Func CheckFastestADConnection()
      Dim $FastestADConnection = 10000, $FastestConnection=""

      _AD_Open()
      $ADDomainArray = _AD_ListDomainControllers()
      _AD_close()

         For $i=1 to ubound($ADDomainArray)-1
            $Ping = Ping($ADDomainArray[$i][2], 10)
            If $Ping < 10 Then
               $ADConnectionTest = TimerInit()
               _AD_Open("", "", "", $ADDomainArray[$i][2], "")
               _AD_Close()

               $TimerDiff = Timerdiff($ADConnectionTest)
               ConsoleWrite($ADDomainArray[$i][2] & " " & $TimerDiff & @CRLF)
                If $FastestADConnection > $TimerDiff then
                  $FastestADConnection = $TimerDiff
                  $FastestConnection = $ADDomainArray[$i][2]
               EndIf
            EndIf
         Next
      Return $FastestConnection
   EndFunc

1. Connects to AD using local details

2. Gets a List of all the Domain Controllers

3. Pings each controller if its less < 10 then controller is online

4. Open / Close connection, recording time to complete this

5. Compares against last controller timer, lowest gets stored.

 

Is this a good way to find out which controller is the fastest?

Ian

Edited by IanN1990

Share this post


Link to post
Share on other sites

How many DCs are we talking about?
IIRC when connecting to a domain Windows selects the best/fastest DC if you do not specify one. So I think just calling _AD_Open() should give you the best result.

Maybe this PS helps: https://blogs.msdn.microsoft.com/javaller/2013/07/29/powershell-one-liner-for-finding-lowest-latency-domain-controller/


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

#7 ·  Posted (edited)

A ping to just the domainname should get you are reply from the "nearest" DC if I remember correctly.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I have 8 domain controllers, using the ping command i get a response of either 1 or 5

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