Jump to content

Getting information about active domain network


Recommended Posts

In my Network and Sharing center you can see (see screenshot) that I have an active domain network.

Is there a way to …

  1. determine the active networks with AutoIt,
  2. find out whether one of them is a domain network and
  3. if one is found, obtain the IP address associated with it?

In my opinion, you could also go the other way round and …

  1. collect the IP addresses of the macros @IPAddress1 to 4 and
  2. check each address to see whether it belongs to an active domain network.

Regards,
DonChunior

NetworkandSharingcenter-gettinginfoaboutdomainnetwork.thumb.png.2bd03d64c4af67cc7866610babc4998d.png

Edited by DonChunior
Link to comment
Share on other sites

I started here to get a list of networks.
MS information can be found here.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I use the following script to check that the computer is connected to an AD domain:

; #INTERNAL_USE_ONLY#============================================================================================================
; Name ..........: __NetworkCheck
; Description ...: Check if the local machine is connected to a domain.
; Syntax ........: __NetworkCheck()
; Parameters ....: None
; Return values .: Success - One of the following integer values:
;                  |0 - The local machine is not connected to a domain
;                  |1 - The local machine is connected to a domain
;                  Failure - 0 and sets @error to one of the following values:
;                  |1 = Could not create the NLM object
;                  |2 = Could not create the NetworkConnections object
;                  |3 = Could not create the Network object
; Author ........: water
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: https://learn.microsoft.com/en-us/windows/win32/NLA/portal
;                  https://www.autoitscript.com/forum/topic/174245-get-connected-networks/?do=findComment&comment=1261045
; Example .......:
; ===============================================================================================================================
Func __NetworkCheck()
    ; NLM_DOMAIN_TYPE: The NLM_DOMAIN_TYPE enumeration is a set of flags that specify the domain type of a network.
    ; See: https://learn.microsoft.com/en-us/windows/win32/api/netlistmgr/ne-netlistmgr-nlm_domain_type
    Local Const $NLM_DOMAIN_TYPE_NON_DOMAIN_NETWORK = 0
    Local Const $NLM_DOMAIN_TYPE_DOMAIN_NETWORK = 0x1
    Local Const $NLM_DOMAIN_TYPE_DOMAIN_AUTHENTICATED = 0x2
    #forceref $NLM_DOMAIN_TYPE_NON_DOMAIN_NETWORK
    Local $bConnected2Domain = False
    Local $sNLM_ClsID = "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"
    Local $oNLM, $oNetworkConnections, $oNetwork
    $oNLM = ObjCreate($sNLM_ClsID)                                ; Create the object for the Network List Manager
    If @error Then Return SetError(1, @error, 0)
    If $oNLM.IsConnected Then                                     ; The local machine has network connectivity, check details
        $oNetworkConnections = $oNLM.GetNetworkConnections        ; Get the collection of NetworkConnections
        If @error Then Return SetError(2, @error, 0)
        For $oNetworkConnection In $oNetworkConnections           ; Check each NetworkConnection
            $oNetwork = $oNetworkConnection.GetNetwork
            If @error Then Return SetError(3, @error, 0)
            If $oNetwork.IsConnected = True And ($oNetwork.GetDomainType = $NLM_DOMAIN_TYPE_DOMAIN_NETWORK Or $oNetwork.GetDomainType = $NLM_DOMAIN_TYPE_DOMAIN_AUTHENTICATED) Then $bConnected2Domain = True
        Next
        Return ($bConnected2Domain = True) ? 1 : 0
    Else
        Return 0
    EndIf
EndFunc   ;==>__NetworkCheck

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...