private void SetInformationAboutNetworkAdapters(SystemInformation systemInformation, IEnumerable <WmiObject> informationAboutNetworkAdapter) { if (!this.TheListIsEmpty(informationAboutNetworkAdapter)) { WmiObject wmiObject = informationAboutNetworkAdapter.First(); NetworkInterface networkInterface = new NetworkInterface(); networkInterface.IpAddress = ((string[])wmiObject.GetValueOf("IPAddress"))[0]; networkInterface.MacAddress = wmiObject.GetValueOf("MACAddress").ToString(); networkInterface.Name = wmiObject.GetValueOf("Description").ToString(); systemInformation.Interfaces.Add(networkInterface); } }
private void SetInformationAboutOperationalSystem(SystemInformation systemInformation, IEnumerable <WmiObject> informationAboutOperationalSystem) { if (!this.TheListIsEmpty(informationAboutOperationalSystem)) { WmiObject wmiObject = informationAboutOperationalSystem.First(); systemInformation.SystemName = this.GetSystemName(wmiObject); systemInformation.SystemVersion = wmiObject.GetValueOf("Version").ToString(); } }
/// <summary> /// Gets the name of the system. /// </summary> /// <param name="wmiObject">The WMI object.</param> /// <returns></returns> private string GetSystemName(WmiObject wmiObject) { string osName = wmiObject.GetValueOf("Name").ToString(); osName = osName.Split('|')[0].Trim(); osName = osName.Replace("®", ""); osName = osName.Replace("™", ""); ushort spmajor = (ushort)wmiObject.GetValueOf("ServicePackMajorVersion"); ushort spminor = (ushort)wmiObject.GetValueOf("ServicePackMinorVersion"); if (spmajor > 0) { osName += " SP" + spmajor.ToString(); if (spminor > 0) { osName += "." + spminor.ToString(); } } return(osName); }
private void collectSidItemSystemData(sid_sid_item sidItem) { string trusteeSID = sidItem.trustee_sid.Value; IEnumerable <WmiObject> wmiObjects = this.searchSIDObjectsOnTarget(trusteeSID); if ((wmiObjects == null) || (wmiObjects.Count() == 0)) { throw new KeyNotFoundException(); } WmiObject userAccount = wmiObjects.First(); sidItem.trustee_domain = OvalHelper.CreateItemEntityWithStringValue(userAccount.GetFieldValueAsString("Domain")); sidItem.trustee_name = OvalHelper.CreateItemEntityWithStringValue(userAccount.GetValueOf("Name").ToString()); }
private string GetArchitecture(WmiObject wmiObject) { string systemType = wmiObject.GetValueOf("SystemType").ToString(); switch (systemType) { case "X86-based PC": case "X86-Nec98 PC": systemType = "INTEL32"; break; case "MIPS-based PC": systemType = "MIPS"; break; case "Alpha-based PC": systemType = "ALPHA32"; break; case "Power PC": systemType = "POWERPC32"; break; case "SH-x PC": systemType = "SUPERH"; break; case "StrongARM PC": systemType = "STRONGARM"; break; case "64-bit Intel PC": systemType = "INTEL64"; break; case "64-bit Alpha PC": systemType = "ALPHA64"; break; default: systemType = "UNKNOWN"; break; } return(systemType); }
/// <summary> /// Return the name of host name concatenated with the domain name. /// </summary> /// <param name="wmiObject">The WMI object.</param> /// <returns></returns> private string GetHostName(WmiObject wmiObject) { string hostName = wmiObject.GetFieldValueAsString("DNSHostName").ToLower(); if (string.IsNullOrEmpty(hostName)) { hostName = wmiObject.GetFieldValueAsString("Name").ToLower(); } object partOfDomain = wmiObject.GetValueOf("PartOfDomain"); if ((partOfDomain != null) && ((bool)partOfDomain)) { hostName += "." + wmiObject.GetFieldValueAsString("Domain"); } return(hostName); }