Skip to content

Commit

Permalink
few changes related to depth and recursive checks, hopefully this works
Browse files Browse the repository at this point in the history
  • Loading branch information
santisq committed Sep 6, 2024
1 parent cd8506e commit 6cd3479
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/PSADTree/Commands/GetADTreeGroupMemberCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private TreeObjectBase ProcessPrincipal(

TreeObjectBase AddTreeObject(TreeObjectBase obj)
{
if (Recursive.IsPresent || depth <= Depth)
if (depth <= Depth)
{
_index.AddPrincipal(obj);
}
Expand Down Expand Up @@ -213,7 +213,6 @@ TreeObjectBase HandleGroup(

private void EnumerateMembers(TreeGroup parent, int depth)
{
bool shouldProcess = Recursive.IsPresent || depth <= Depth;
foreach (TreeObjectBase member in parent.Childs)
{
if (member is TreeGroup treeGroup)
Expand All @@ -222,7 +221,7 @@ private void EnumerateMembers(TreeGroup parent, int depth)
continue;
}

if (shouldProcess)
if (depth <= Depth)
{
_index.Add(member.Clone(parent, depth));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ TreeGroup ProcessGroup(GroupPrincipal group)

private void EnumerateMembership(TreeGroup parent, int depth)
{
if (!Recursive.IsPresent && depth > Depth)
if (depth > Depth)
{
return;
}
Expand Down
15 changes: 12 additions & 3 deletions src/PSADTree/PSADTreeCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ protected override void BeginProcessing()
{
try
{
if (Recursive.IsPresent)
{
Depth = int.MaxValue;
}

if (Exclude is not null)
{
_exclusionPatterns = Exclude
Expand Down Expand Up @@ -103,13 +108,17 @@ protected override void BeginProcessing()

protected void Push(GroupPrincipal? groupPrincipal, TreeGroup treeGroup)
{
if (Recursive.IsPresent || treeGroup.Depth <= Depth)
if (treeGroup.Depth > Depth)
{
_stack.Push((groupPrincipal, treeGroup));
return;
}

_truncatedOutput = true;
if (treeGroup.Depth == Depth)
{
_truncatedOutput = true;
}

_stack.Push((groupPrincipal, treeGroup));
}

protected void DisplayWarningIfTruncatedOutput()
Expand Down

0 comments on commit 6cd3479

Please sign in to comment.