Win32_Networkadapterconfiguration and DNSDomain

  • Thread starter Thread starter auldh
  • Start date Start date
A

auldh

hello,
i have gotten my code running well. it collect the network card information
by way of Win32_networkadapterconfiguration but when it comes to the
DNSDomain output i'm get null. always null.
i run the ipconfig /all and there is data. but using the win32_... i get null.

int i = 0;
bool bStat = false;
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection queryCollection = query.Get();
i = queryCollection.Count;
string[] addresses;
foreach (ManagementObject snic in queryCollection)
{
XHF.defInst.xprhotfixviewer.Text += "NIC Name: " + "\t" +
snic["Description"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "MAC Address: " + "\t" +
snic["MACAddress"] + "\r\n";
if (snic["IPAddress"] != null)
{
addresses = (string[])snic["IPAddress"];
foreach (string ipaddress in addresses)
{
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t" +
ipaddress + "\r\n";
}
}
else
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t";
XHF.defInst.xprhotfixviewer.Text += "DHCP Server: " + "\t" +
snic["DHCPServer"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "DNS Domain: " + "\t" +
snic["DNSDomain"] + "\r\n";

according to documentation this is a "string".
 
auldh said:
hello,
i have gotten my code running well. it collect the network card
information
by way of Win32_networkadapterconfiguration but when it comes to the
DNSDomain output i'm get null. always null.
i run the ipconfig /all and there is data. but using the win32_... i get
null.

int i = 0;
bool bStat = false;
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT *
FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection queryCollection = query.Get();
i = queryCollection.Count;
string[] addresses;
foreach (ManagementObject snic in queryCollection)
{
XHF.defInst.xprhotfixviewer.Text += "NIC Name: " + "\t" +
snic["Description"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "MAC Address: " + "\t" +
snic["MACAddress"] + "\r\n";
if (snic["IPAddress"] != null)
{
addresses = (string[])snic["IPAddress"];
foreach (string ipaddress in addresses)
{
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t" +
ipaddress + "\r\n";
}
}
else
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t";
XHF.defInst.xprhotfixviewer.Text += "DHCP Server: " + "\t" +
snic["DHCPServer"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "DNS Domain: " + "\t" +
snic["DNSDomain"] + "\r\n";

according to documentation this is a "string".




DNSDomain contains the IP domain name if the system runs a DNS, I guess this
is not the case here.

Willy.
 
so what is my next option? i know "ipconfig" does get it what am i doing
wrong or how can i ensure the data?


Willy Denoyette said:
auldh said:
hello,
i have gotten my code running well. it collect the network card
information
by way of Win32_networkadapterconfiguration but when it comes to the
DNSDomain output i'm get null. always null.
i run the ipconfig /all and there is data. but using the win32_... i get
null.

int i = 0;
bool bStat = false;
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT *
FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection queryCollection = query.Get();
i = queryCollection.Count;
string[] addresses;
foreach (ManagementObject snic in queryCollection)
{
XHF.defInst.xprhotfixviewer.Text += "NIC Name: " + "\t" +
snic["Description"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "MAC Address: " + "\t" +
snic["MACAddress"] + "\r\n";
if (snic["IPAddress"] != null)
{
addresses = (string[])snic["IPAddress"];
foreach (string ipaddress in addresses)
{
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t" +
ipaddress + "\r\n";
}
}
else
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t";
XHF.defInst.xprhotfixviewer.Text += "DHCP Server: " + "\t" +
snic["DHCPServer"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "DNS Domain: " + "\t" +
snic["DNSDomain"] + "\r\n";

according to documentation this is a "string".




DNSDomain contains the IP domain name if the system runs a DNS, I guess this
is not the case here.

Willy.
 
auldh said:
so what is my next option? i know "ipconfig" does get it what am i doing
wrong or how can i ensure the data?

What ipconfig info are you actually talking about?
All ipconfig returns are the "DNS server addresses" that can be used for IP
address resolution, but this is not what WMI's "DNSDomain" is all about. The
DSN server addresses are found in the "DNSServerSearchOrder" property.

Willy.

Willy Denoyette said:
auldh said:
hello,
i have gotten my code running well. it collect the network card
information
by way of Win32_networkadapterconfiguration but when it comes to the
DNSDomain output i'm get null. always null.
i run the ipconfig /all and there is data. but using the win32_... i
get
null.

int i = 0;
bool bStat = false;
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT *
FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection queryCollection = query.Get();
i = queryCollection.Count;
string[] addresses;
foreach (ManagementObject snic in queryCollection)
{
XHF.defInst.xprhotfixviewer.Text += "NIC Name: " + "\t" +
snic["Description"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "MAC Address: " + "\t" +
snic["MACAddress"] + "\r\n";
if (snic["IPAddress"] != null)
{
addresses = (string[])snic["IPAddress"];
foreach (string ipaddress in addresses)
{
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t"
+
ipaddress + "\r\n";
}
}
else
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t";
XHF.defInst.xprhotfixviewer.Text += "DHCP Server: " + "\t" +
snic["DHCPServer"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "DNS Domain: " + "\t" +
snic["DNSDomain"] + "\r\n";

according to documentation this is a "string".




DNSDomain contains the IP domain name if the system runs a DNS, I guess
this
is not the case here.

Willy.
 
hello Willy,
i checked my code and i do collect the "DNSServerSearchOrder" this returns
the ip address for the DNS server.

i was looking for the "Primary DNS Suffix" string which a domain computer
usually has. that information i don't seem to find. maybe this is stored some
where else. i would like to collect for the local and remote computer.

Willy Denoyette said:
auldh said:
so what is my next option? i know "ipconfig" does get it what am i doing
wrong or how can i ensure the data?

What ipconfig info are you actually talking about?
All ipconfig returns are the "DNS server addresses" that can be used for IP
address resolution, but this is not what WMI's "DNSDomain" is all about. The
DSN server addresses are found in the "DNSServerSearchOrder" property.

Willy.

Willy Denoyette said:
hello,
i have gotten my code running well. it collect the network card
information
by way of Win32_networkadapterconfiguration but when it comes to the
DNSDomain output i'm get null. always null.
i run the ipconfig /all and there is data. but using the win32_... i
get
null.

int i = 0;
bool bStat = false;
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT *
FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection queryCollection = query.Get();
i = queryCollection.Count;
string[] addresses;
foreach (ManagementObject snic in queryCollection)
{
XHF.defInst.xprhotfixviewer.Text += "NIC Name: " + "\t" +
snic["Description"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "MAC Address: " + "\t" +
snic["MACAddress"] + "\r\n";
if (snic["IPAddress"] != null)
{
addresses = (string[])snic["IPAddress"];
foreach (string ipaddress in addresses)
{
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t"
+
ipaddress + "\r\n";
}
}
else
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t";
XHF.defInst.xprhotfixviewer.Text += "DHCP Server: " + "\t" +
snic["DHCPServer"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "DNS Domain: " + "\t" +
snic["DNSDomain"] + "\r\n";

according to documentation this is a "string".




DNSDomain contains the IP domain name if the system runs a DNS, I guess
this
is not the case here.

Willy.
 
On a local system and supposing you are running on V2 of the framework, you
can get the DomainName property from the IPGlobalProperties
class(System.Net.NetworkInformation namespace).

On a remote system, you'll have to get the Domain property of
Win32_ComputerSystem using System.Management.

Willy.

auldh said:
hello Willy,
i checked my code and i do collect the "DNSServerSearchOrder" this returns
the ip address for the DNS server.

i was looking for the "Primary DNS Suffix" string which a domain computer
usually has. that information i don't seem to find. maybe this is stored
some
where else. i would like to collect for the local and remote computer.

Willy Denoyette said:
auldh said:
so what is my next option? i know "ipconfig" does get it what am i
doing
wrong or how can i ensure the data?

What ipconfig info are you actually talking about?
All ipconfig returns are the "DNS server addresses" that can be used for
IP
address resolution, but this is not what WMI's "DNSDomain" is all about.
The
DSN server addresses are found in the "DNSServerSearchOrder" property.

Willy.

:

hello,
i have gotten my code running well. it collect the network card
information
by way of Win32_networkadapterconfiguration but when it comes to the
DNSDomain output i'm get null. always null.
i run the ipconfig /all and there is data. but using the win32_... i
get
null.

int i = 0;
bool bStat = false;
ManagementObjectSearcher query = new
ManagementObjectSearcher("SELECT *
FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection queryCollection = query.Get();
i = queryCollection.Count;
string[] addresses;
foreach (ManagementObject snic in queryCollection)
{
XHF.defInst.xprhotfixviewer.Text += "NIC Name: " + "\t" +
snic["Description"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "MAC Address: " + "\t" +
snic["MACAddress"] + "\r\n";
if (snic["IPAddress"] != null)
{
addresses = (string[])snic["IPAddress"];
foreach (string ipaddress in addresses)
{
XHF.defInst.xprhotfixviewer.Text += "IP Address: " +
"\t"
+
ipaddress + "\r\n";
}
}
else
XHF.defInst.xprhotfixviewer.Text += "IP Address: " + "\t";
XHF.defInst.xprhotfixviewer.Text += "DHCP Server: " + "\t" +
snic["DHCPServer"] + "\r\n";
XHF.defInst.xprhotfixviewer.Text += "DNS Domain: " + "\t" +
snic["DNSDomain"] + "\r\n";

according to documentation this is a "string".




DNSDomain contains the IP domain name if the system runs a DNS, I
guess
this
is not the case here.

Willy.
 
Back
Top