Ejemplo n.º 1
0
 private void InitializeNetworkAdapters(ManagementObject networkAdapter, NetworkInterface networkInterface = null)
 {
     this.networkAdapter   = networkAdapter;
     this.networkInterface = networkInterface ?? DNSHelper.GetNetworkInterface(this.networkAdapter.GetPropertyValue <string>("Description"));
     this.MACAddress       = this.networkAdapter.GetPropertyValue <string>("MACAddress").ToPhysicalAddress().GetAddressBytes();
     this.DNSConfiguration = this.GetDNSConfiguration();
     this.IPAddress        = IPAddress.Parse(this.networkAdapter.GetPropertyValue <string[]>("IPAddress").FirstOrDefault());
     this.DeviceName       = this.networkInterface.Description;;
 }
Ejemplo n.º 2
0
        public uint SetDNSConfiguration(DNSConfiguration configuration)
        {
            ManagementBaseObject args = this.networkAdapter.GetMethodParameters("SetDNSServerSearchOrder");

            args["DNSServerSearchOrder"] = configuration.ToArray();

            ManagementBaseObject invokeResult = this.networkAdapter.InvokeMethod("SetDNSServerSearchOrder", args, null);
            uint returnValue = (uint)invokeResult["ReturnValue"];

            if (returnValue == 0)
            {
                this.DNSConfiguration = configuration;
            }

            return(returnValue);
        }