Пример #1
0
        /// <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);
        }
Пример #2
0
        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());
        }