Пример #1
0
        protected override IEnumerable <CollectedItem> collectDataForSystemItem(ItemType systemItem)
        {
            if (systemItem.status.Equals(StatusEnumeration.notcollected))
            {
                var itemTypeBuilder = new RegKeyEffectiveRightsItemTypeBuilder((regkeyeffectiverights_item)systemItem);
                var hive            = ((regkeyeffectiverights_item)systemItem).hive;
                var registryKey     = ((regkeyeffectiverights_item)systemItem).key;
                var trusteeSID      = ((regkeyeffectiverights_item)systemItem).trustee_sid;

                try
                {
                    base.ExecutionLogBuilder.AddInfo(string.Format(LOG_START_COLLECTING, trusteeSID.Value, registryKey.Value));
                    var collectedDACL = this.GetRegistryKeyACLForUser(hive.Value, registryKey.Value, trusteeSID.Value);
                    itemTypeBuilder.FillItemTypeWithData(collectedDACL);

                    systemItem.status = StatusEnumeration.exists;
                }
                catch (UserDACLNotFoundOnRegistryException)
                {
                    SetDoesNotExistStatusForItemType(systemItem, trusteeSID.Value);
                    itemTypeBuilder.SetItemTypeEntityStatus(trusteeSID, StatusEnumeration.doesnotexist);
                }
                catch (RegistryKeyEffectiveRightsNotFoundException)
                {
                    SetDoesNotExistStatusForItemType(systemItem, Path.Combine(hive.Value, registryKey.Value));
                    itemTypeBuilder.SetItemTypeEntityStatus(hive, StatusEnumeration.doesnotexist);
                    itemTypeBuilder.SetItemTypeEntityStatus(registryKey, StatusEnumeration.doesnotexist);
                }
                catch (RegistryKeyEffectiveRightsAccessDenied regKeyAccessDeniedException)
                {
                    itemTypeBuilder.SetItemTypeEntityStatus(hive, StatusEnumeration.error);
                    itemTypeBuilder.SetItemTypeEntityStatus(registryKey, StatusEnumeration.error);
                    throw new Exception(regKeyAccessDeniedException.Message);
                }

                itemTypeBuilder.BuildItemType();
                return(new ItemTypeHelper().CreateCollectedItemsWithOneItem(itemTypeBuilder.BuiltItemType, BuildExecutionLog()));
            }

            return(new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog()));
        }
        protected override IEnumerable<CollectedItem> collectDataForSystemItem(ItemType systemItem)
        {
            if (systemItem.status.Equals(StatusEnumeration.notcollected))
            {
                var itemTypeBuilder = new RegKeyEffectiveRightsItemTypeBuilder((regkeyeffectiverights_item)systemItem);
                var hive = ((regkeyeffectiverights_item)systemItem).hive;
                var registryKey = ((regkeyeffectiverights_item)systemItem).key;
                var trusteeSID = ((regkeyeffectiverights_item)systemItem).trustee_sid;

                try
                {
                    base.ExecutionLogBuilder.AddInfo(string.Format(LOG_START_COLLECTING, trusteeSID.Value, registryKey.Value));
                    var collectedDACL = this.GetRegistryKeyACLForUser(hive.Value, registryKey.Value, trusteeSID.Value);
                    itemTypeBuilder.FillItemTypeWithData(collectedDACL);

                    systemItem.status = StatusEnumeration.exists;
                }
                catch (UserDACLNotFoundOnRegistryException)
                {
                    SetDoesNotExistStatusForItemType(systemItem, trusteeSID.Value);
                    itemTypeBuilder.SetItemTypeEntityStatus(trusteeSID, StatusEnumeration.doesnotexist);
                }
                catch (RegistryKeyEffectiveRightsNotFoundException)
                {
                    SetDoesNotExistStatusForItemType(systemItem, Path.Combine(hive.Value, registryKey.Value));
                    itemTypeBuilder.SetItemTypeEntityStatus(hive, StatusEnumeration.doesnotexist);
                    itemTypeBuilder.SetItemTypeEntityStatus(registryKey, StatusEnumeration.doesnotexist);
                }
                catch (RegistryKeyEffectiveRightsAccessDenied regKeyAccessDeniedException)
                {
                    itemTypeBuilder.SetItemTypeEntityStatus(hive, StatusEnumeration.error);
                    itemTypeBuilder.SetItemTypeEntityStatus(registryKey, StatusEnumeration.error);
                    throw new Exception(regKeyAccessDeniedException.Message);
                }

                itemTypeBuilder.BuildItemType();
                return new ItemTypeHelper().CreateCollectedItemsWithOneItem(itemTypeBuilder.BuiltItemType, BuildExecutionLog());
            }

            return new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog());
        }