Avoid repeated NTFS engine logger initialization
This commit is contained in:
@@ -1335,9 +1335,17 @@ namespace C4IT.LIAM
|
||||
IEnumerable<string> readerSids,
|
||||
IEnumerable<string> writerSids)
|
||||
{
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine creation stage. Stage=Start Path='{folderPath}', ParentPath='{parentFolderPath}'",
|
||||
LogLevels.Debug);
|
||||
|
||||
var requiresDomainLocalTag = this.GroupStrategy == eLiamGroupStrategies.Ntfs_AGDLP
|
||||
|| (NamingConventions ?? Enumerable.Empty<cLiamNamingConvention>())
|
||||
.Any(i => i.Scope == eLiamAccessRoleScopes.DomainLocal);
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine creation stage finished. Stage=ResolveStrategy Path='{folderPath}', RequiresDomainLocalTag={requiresDomainLocalTag}, Elapsed='{stopwatch.Elapsed}'",
|
||||
LogLevels.Debug);
|
||||
|
||||
var mergedCustomTags = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var tag in CustomTags)
|
||||
@@ -1347,49 +1355,70 @@ namespace C4IT.LIAM
|
||||
foreach (var tag in customTags)
|
||||
mergedCustomTags[tag.Key] = tag.Value;
|
||||
}
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine creation stage finished. Stage=MergeCustomTags Path='{folderPath}', CustomTags={mergedCustomTags.Count}, Elapsed='{stopwatch.Elapsed}'",
|
||||
LogLevels.Debug);
|
||||
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine creation stage. Stage=ConstructEngine Path='{folderPath}'",
|
||||
LogLevels.Debug);
|
||||
var engine = new DataArea_FileSystem();
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine creation stage finished. Stage=ConstructEngine Path='{folderPath}', Elapsed='{stopwatch.Elapsed}'",
|
||||
LogLevels.Debug);
|
||||
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine creation stage. Stage=AssignEngineProperties Path='{folderPath}'",
|
||||
LogLevels.Debug);
|
||||
engine.ConfigID = "manual";
|
||||
engine.domainName = this.Domain;
|
||||
engine.effectiveDomainController = activeDirectoryBase.EffectiveDomainController;
|
||||
engine.username = this.Credential.Identification;
|
||||
engine.password = new NetworkCredential("", this.Credential.Secret).SecurePassword;
|
||||
engine.baseFolder = this.RootPath;
|
||||
engine.newFolderPath = folderPath;
|
||||
engine.newFolderParent = parentFolderPath;
|
||||
engine.groupPrefix = GetRequiredCustomTag("Filesystem_GroupPrefixTag");
|
||||
engine.groupOUPath = this.GroupPath;
|
||||
engine.groupPermissionStrategy = (C4IT_IAM_GET.PermissionGroupStrategy)this.GroupStrategy;
|
||||
engine.groupCustomTags = mergedCustomTags;
|
||||
engine.ownerUserSids = ownerSids?.Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList() ?? new List<string>();
|
||||
engine.readerUserSids = readerSids?.Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList() ?? new List<string>();
|
||||
engine.writerUserSids = writerSids?.Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList() ?? new List<string>();
|
||||
engine.groupOwnerTag = GetRequiredCustomTag("Filesystem_GroupOwnerTag");
|
||||
engine.groupWriteTag = GetRequiredCustomTag("Filesystem_GroupWriteTag");
|
||||
engine.groupReadTag = GetRequiredCustomTag("Filesystem_GroupReadTag");
|
||||
engine.groupTraverseTag = GetRequiredCustomTag("Filesystem_GroupTraverseTag");
|
||||
engine.groupDLTag = requiresDomainLocalTag ? GetRequiredCustomTag("Filesystem_GroupDomainLocalTag") : string.Empty;
|
||||
engine.groupGTag = GetRequiredCustomTag("Filesystem_GroupGlobalTag");
|
||||
engine.CanManagePermissionsForPath = IsPermissionManagedFolderPath;
|
||||
engine.CanManageTraversePermissionsForPath = IsTraversePermissionManagedPath;
|
||||
engine.forceStrictAdGroupNames = IsAdditionalConfigurationEnabled("ForceStrictAdGroupNames");
|
||||
engine.groupNameSanitizeReplacement = GetAdditionalConfigurationValueOrDefault(
|
||||
AdditionalConfigurationGroupNameSanitizeReplacementKey,
|
||||
Helper.DefaultGroupNameSanitizeReplacement);
|
||||
engine.preserveAdGroupNameCase = IsAdditionalConfigurationEnabled(AdditionalConfigurationPreserveAdGroupNameCaseKey);
|
||||
engine.OwnerACLPermission = this.OwnerACLPermission;
|
||||
engine.WriteACLPermission = this.WriteACLPermission;
|
||||
engine.ReadACLPermission = this.ReadACLPermission;
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine creation stage finished. Stage=AssignEngineProperties Path='{folderPath}', Elapsed='{stopwatch.Elapsed}'",
|
||||
LogLevels.Debug);
|
||||
|
||||
var engine = new DataArea_FileSystem
|
||||
{
|
||||
ConfigID = "manual",
|
||||
domainName = this.Domain,
|
||||
effectiveDomainController = activeDirectoryBase.EffectiveDomainController,
|
||||
username = this.Credential.Identification,
|
||||
password = new NetworkCredential("", this.Credential.Secret).SecurePassword,
|
||||
baseFolder = this.RootPath,
|
||||
newFolderPath = folderPath,
|
||||
newFolderParent = parentFolderPath,
|
||||
groupPrefix = GetRequiredCustomTag("Filesystem_GroupPrefixTag"),
|
||||
groupOUPath = this.GroupPath,
|
||||
groupPermissionStrategy = (C4IT_IAM_GET.PermissionGroupStrategy)this.GroupStrategy,
|
||||
groupCustomTags = mergedCustomTags,
|
||||
ownerUserSids = ownerSids?.Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList() ?? new List<string>(),
|
||||
readerUserSids = readerSids?.Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList() ?? new List<string>(),
|
||||
writerUserSids = writerSids?.Where(i => !string.IsNullOrWhiteSpace(i)).Distinct(StringComparer.OrdinalIgnoreCase).ToList() ?? new List<string>(),
|
||||
groupOwnerTag = GetRequiredCustomTag("Filesystem_GroupOwnerTag"),
|
||||
groupWriteTag = GetRequiredCustomTag("Filesystem_GroupWriteTag"),
|
||||
groupReadTag = GetRequiredCustomTag("Filesystem_GroupReadTag"),
|
||||
groupTraverseTag = GetRequiredCustomTag("Filesystem_GroupTraverseTag"),
|
||||
groupDLTag = requiresDomainLocalTag ? GetRequiredCustomTag("Filesystem_GroupDomainLocalTag") : string.Empty,
|
||||
groupGTag = GetRequiredCustomTag("Filesystem_GroupGlobalTag"),
|
||||
CanManagePermissionsForPath = IsPermissionManagedFolderPath,
|
||||
CanManageTraversePermissionsForPath = IsTraversePermissionManagedPath,
|
||||
forceStrictAdGroupNames = IsAdditionalConfigurationEnabled("ForceStrictAdGroupNames"),
|
||||
groupNameSanitizeReplacement = GetAdditionalConfigurationValueOrDefault(
|
||||
AdditionalConfigurationGroupNameSanitizeReplacementKey,
|
||||
Helper.DefaultGroupNameSanitizeReplacement),
|
||||
preserveAdGroupNameCase = IsAdditionalConfigurationEnabled(AdditionalConfigurationPreserveAdGroupNameCaseKey),
|
||||
OwnerACLPermission = this.OwnerACLPermission,
|
||||
WriteACLPermission = this.WriteACLPermission,
|
||||
ReadACLPermission = this.ReadACLPermission
|
||||
};
|
||||
engine.traverseBoundaryPath = GetEffectiveTraverseBoundaryPath();
|
||||
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine ACL permissions: Owner=0x{engine.OwnerACLPermission:X}, Write=0x{engine.WriteACLPermission:X}, Read=0x{engine.ReadACLPermission:X}",
|
||||
LogLevels.Debug);
|
||||
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine creation stage. Stage=BuildSecurityGroupTemplates Path='{folderPath}'",
|
||||
LogLevels.Debug);
|
||||
foreach (var template in BuildSecurityGroupTemplates())
|
||||
engine.templates.Add(template);
|
||||
LogEntry(
|
||||
$"NTFS filesystem engine creation stage finished. Stage=BuildSecurityGroupTemplates Path='{folderPath}', Templates={engine.templates.Count}, Elapsed='{stopwatch.Elapsed}'",
|
||||
LogLevels.Debug);
|
||||
|
||||
return engine;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user