Recently Browsing 0 members
No registered users viewing this page.
Can not get my head around this one.
This function gets the DNS object s
If you have two DNS entries fine. but if you have only one! Trouble
$objItem.DNSServerSearchOrder = Primary DNS
$objItem.DNSServerSearchOrder = Secondry DNS not always there. I need a way to return 0 if not there or the IP if its there.
Or is there a way to tell how many objects there are in the "[?]"
I'm terrible at WMI errors, thanks for help in advance.
Func _GETcurrentNICinfo2() $oErrors = ObjEvent("AutoIt.Error", "Error_Handle") Local $DnsSecondry Local $objWMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" ) Local $query = $objWMIService.ExecQuery("SELECT DNSServerSearchOrder FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 ) If @error Then Return 0 If NOT IsObj($query) Then Return 0 Else For $objItem In $query Return $objItem.DNSServerSearchOrder next Endif EndFunc
Last morning I needed to know programmatically which were my DNS(s) for the current connection, and I searched for an API which fitted my needs... I just tried dnsqueryconfig, which shows the DNS(s) used, if you have manually selected them in the past.
The API is little tricky (or maybe I'm little rusty), so I decided to write a small UDF function to avoid a waste of time in the future... here you are.
; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_DnsQueryConfig ; Description ...: Retrieves the currently used DNS servers, if they were selected by user ; Syntax.........: _WinAPI_DnsQueryConfig() ; Return values .: On success it returns an array with the list of currently used DNS servers ; ; On failure it returns 0 and sets @error to non zero (these values are useful only for debugging reasons): ; |1 - DllCall error ; |2 - Generic error, DNS could be generated automatically ; Author ........: j0kky ; Modified ......: 1.0.0 14/11/2018 ; Link ..........: https://docs.microsoft.com/en-us/windows/desktop/api/windns/nf-windns-dnsqueryconfig ; =============================================================================================================================== Func _WinAPI_DnsQueryConfig() Local Const $DnsConfigDnsServerList = 6 Local $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", Null, "dword*", 0) If @error Then Return SetError(1, 0, 0) if $aRet <= 4 Then Return SetError(2, 0, 0) Local $tagBuffer = "" For $i = 1 To ($aRet / 4) $tagBuffer &= "dword;" Next Local $tBuffer = DllStructCreate($tagBuffer) $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", DllStructGetPtr($tBuffer), "dword*", $aRet) Local $aDNS[($aRet / 4) - 1] For $i = 2 to (UBound($aDNS) + 1) $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "dword", DllStructGetData($tBuffer, $i)) if @error Then Return SetError(1, 0, 0) $aDNS[$i - 2] = $aRet Next Return SetError(0, 0, $aDNS) EndFunc
I hope you can help me with this. I need to connect to a Database using Cloudera ODBC Driver for Impala. I installed the driver, created a User DSN (drona2) and tested it successfully (got the message: Successfully connected to data source!) but when I try to connect to the database using a Conneciton String, it simply didn't work.
I tried connecting to the database using the User DSN, I previously created, that has all parameters needed but got the following error:
$ProviderDatasource = 'DSN=drona2;'
$conn_Database = ObjCreate ("ADODB.Connection")
$conn_Database.ConnectionString = $ProviderDatasource
==> The requested action with this object has failed.:
Also I tried adding all parameters to my connection string as follows but also got the same error:
$ProviderDatasource = 'Driver=Cloudera ODBC Driver for Impala;Host=MyHost.domain.com;PORT=21050;AuthMech=3;UID=MyUserId@domain.com;PWD=MyPasswordc;Schema=default;SSL=1;AllowSelfSignedCerts=1;AllowHostNameCNMismatch=1;CheckCertRevocation=1;KrbFQDN=_HOTS;KrbServiceName=impala;ServicePrincipalCanonicalization=1'
I hope someone has used this driver successfully before and can shed some light here.
If you need additional information, let me know.
Im about to start making an autoit script that will read the current ODBC settings, have a drop down to select a different one which would then update the ODBC in windows to use the new settings.
Can anyone point me in the direction of how to read the ODBC 32 bit settings? are they in the registry?
Hi. I just released this software, we need it to override the DHCP server at work. Our DHCP server does not allow per-mac-address configuration, so I coded this utility to allow our developers to use our area's custom DNS server, regardless of what DHCP provides, and let them have the possibiity to quickly shift to automatic configuration when they take their laptops home.
An afternoon's worth of coding, and another half day for polish and release. Pretty old-school simplicity; it was a good excercise to finally code some UI using AutoIt.
Hope it's useful to someone.