Add classified NTFS path template placeholders
This commit is contained in:
@@ -1342,6 +1342,9 @@ namespace C4IT.LIAM
|
||||
$"NTFS filesystem engine creation stage. Stage=Start Path='{folderPath}', ParentPath='{parentFolderPath}'",
|
||||
LogLevels.Debug);
|
||||
|
||||
var groupNameSanitizeReplacement = GetAdditionalConfigurationValueOrDefault(
|
||||
AdditionalConfigurationGroupNameSanitizeReplacementKey,
|
||||
Helper.DefaultGroupNameSanitizeReplacement);
|
||||
var requiresDomainLocalTag = this.GroupStrategy == eLiamGroupStrategies.Ntfs_AGDLP
|
||||
|| (NamingConventions ?? Enumerable.Empty<cLiamNamingConvention>())
|
||||
.Any(i => i.Scope == eLiamAccessRoleScopes.DomainLocal);
|
||||
@@ -1398,9 +1401,8 @@ namespace C4IT.LIAM
|
||||
engine.forceStrictAdGroupNames = IsAdditionalConfigurationEnabled("ForceStrictAdGroupNames");
|
||||
engine.adGroupReuseMode = GetAdGroupReuseMode();
|
||||
engine.adGroupMarkerBackfill = IsAdditionalConfigurationEnabled(AdditionalConfigurationAdGroupMarkerBackfillKey);
|
||||
engine.groupNameSanitizeReplacement = GetAdditionalConfigurationValueOrDefault(
|
||||
AdditionalConfigurationGroupNameSanitizeReplacementKey,
|
||||
Helper.DefaultGroupNameSanitizeReplacement);
|
||||
engine.groupNameSanitizeReplacement = groupNameSanitizeReplacement;
|
||||
engine.GetTemplateContextForPath = path => GetTemplateContextForPath(path, groupNameSanitizeReplacement);
|
||||
engine.preserveAdGroupNameCase = IsAdditionalConfigurationEnabled(AdditionalConfigurationPreserveAdGroupNameCaseKey);
|
||||
engine.OwnerACLPermission = this.OwnerACLPermission;
|
||||
engine.WriteACLPermission = this.WriteACLPermission;
|
||||
@@ -1427,6 +1429,50 @@ namespace C4IT.LIAM
|
||||
return engine;
|
||||
}
|
||||
|
||||
private Helper.RootPathTemplateContext GetTemplateContextForPath(string path, string groupNameSanitizeReplacement)
|
||||
{
|
||||
var context = Helper.GetRootPathTemplateContext(this.RootPath, groupNameSanitizeReplacement);
|
||||
var normalizedPath = NormalizeUncPath(path);
|
||||
var segments = GetUncSegments(normalizedPath);
|
||||
if (segments.Length > 0)
|
||||
context.ServerName = Helper.SanitizePathSegment(segments[0], groupNameSanitizeReplacement);
|
||||
|
||||
var classification = ClassifyPath(normalizedPath);
|
||||
var dfsPrefixes = GetDfsObjectPrefixes(normalizedPath);
|
||||
if (dfsPrefixes.Count > 0)
|
||||
{
|
||||
context.DfsNamespaceName = GetLastSanitizedPathSegment(dfsPrefixes[0], groupNameSanitizeReplacement);
|
||||
|
||||
if (classification != null && classification.Kind != eNtfsPathKind.DfsNamespaceRoot)
|
||||
context.ShareName = GetLastSanitizedPathSegment(classification.BoundaryPath, groupNameSanitizeReplacement);
|
||||
else
|
||||
context.ShareName = string.Empty;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
if (classification != null
|
||||
&& !string.IsNullOrWhiteSpace(classification.BoundaryPath)
|
||||
&& (classification.Kind == eNtfsPathKind.ClassicShare || classification.Kind == eNtfsPathKind.Folder))
|
||||
{
|
||||
context.ShareName = GetLastSanitizedPathSegment(classification.BoundaryPath, groupNameSanitizeReplacement);
|
||||
}
|
||||
else if (segments.Length > 1)
|
||||
{
|
||||
context.ShareName = Helper.SanitizePathSegment(segments[1], groupNameSanitizeReplacement);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
private string GetLastSanitizedPathSegment(string path, string groupNameSanitizeReplacement)
|
||||
{
|
||||
var segments = GetUncSegments(path);
|
||||
return segments.Length == 0
|
||||
? string.Empty
|
||||
: Helper.SanitizePathSegment(segments[segments.Length - 1], groupNameSanitizeReplacement);
|
||||
}
|
||||
|
||||
private bool IsAdditionalConfigurationEnabled(string key)
|
||||
{
|
||||
if (AdditionalConfiguration == null || string.IsNullOrWhiteSpace(key))
|
||||
|
||||
Reference in New Issue
Block a user