TestimoX

API Reference

Class

SmbShareRepair

Namespace ComputerX.Smb
Assembly ComputerX
Modifiers static

Builds and applies preview-first SMB share permission and ownership repair plans.

Inheritance

  • Object
  • SmbShareRepair

Methods

public static SmbShareRepairResult ApplySharePermissions(SmbSharePermissionRepairPlan plan, Boolean allowWrite) #
Returns: SmbShareRepairResult

Applies a share permission repair plan only when explicit write approval is provided.

Parameters

plan ComputerX.Smb.SmbSharePermissionRepairPlan requiredposition: 0
Plan to apply.
allowWrite System.Boolean requiredposition: 1
Must be true to apply the plan.

Returns

Repair result. When allowWrite is false, the result is a preview.

Examples


SmbShareRepairResult preview = SmbShareRepair.ApplySharePermissions(plan, allowWrite: false);
SmbShareRepairResult applied = SmbShareRepair.ApplySharePermissions(plan, allowWrite: true);
            
public static SmbShareRepairResult ApplyShareRootOwner(SmbShareOwnershipRepairPlan plan, Boolean allowWrite) #
Returns: SmbShareRepairResult

Applies a share root ownership plan only when explicit write approval is provided.

Parameters

plan ComputerX.Smb.SmbShareOwnershipRepairPlan requiredposition: 0
Ownership repair plan.
allowWrite System.Boolean requiredposition: 1
Must be true to apply the plan.

Returns

Repair result. When allowWrite is false, the result is a preview.

Examples


SmbShareRepairResult preview = SmbShareRepair.ApplyShareRootOwner(ownerPlan, allowWrite: false);
SmbShareRepairResult applied = SmbShareRepair.ApplyShareRootOwner(ownerPlan, allowWrite: true);
            
public static SmbSharePermissionRepairPlan PlanSharePermissions(String computerName, String shareName, IReadOnlyList<SmbSharePermissionDesiredEntry> desiredEntries, SmbSharePermissionRepairMode mode = Merge) #
Returns: SmbSharePermissionRepairPlan

Builds a share permission repair plan without applying it.

Parameters

computerName System.String requiredposition: 0
Target computer. Empty, null, or "." uses the local computer.
shareName System.String requiredposition: 1
Share whose permissions should be planned.
desiredEntries System.Collections.Generic.IReadOnlyList{ComputerX.Smb.SmbSharePermissionDesiredEntry} requiredposition: 2
Desired share-level permission entries.
mode ComputerX.Smb.SmbSharePermissionRepairMode = Merge optionalposition: 3
Merge or replace behavior.

Returns

Permission repair plan.

Examples


SmbSharePermissionRepairPlan plan = SmbShareRepair.PlanSharePermissions(
    "FS01",
    "Finance",
    new[]
    {
        new SmbSharePermissionDesiredEntry { Identity = @"CONTOSO\File Admins", Rights = SmbShareRights.FullControl },
        new SmbSharePermissionDesiredEntry { Identity = @"CONTOSO\Finance", Rights = SmbShareRights.Change }
    },
    SmbSharePermissionRepairMode.Replace);
            
public static SmbShareOwnershipRepairPlan PlanShareRootOwner(SmbShareDiagnosticItem diagnosticItem, String desiredOwner) #
Returns: SmbShareOwnershipRepairPlan

Builds an ownership repair plan for a share root.

Parameters

diagnosticItem ComputerX.Smb.SmbShareDiagnosticItem requiredposition: 0
Share diagnostic item containing share path and optional NTFS ACL evidence.
desiredOwner System.String requiredposition: 1
Desired owner account or SID.

Returns

Ownership repair plan.

Examples


SmbShareDiagnosticResult diagnostics = SmbShareDiagnostics.Get(
    new SmbShareDiagnosticOptions { ShareNames = new[] { "Finance" } });

SmbShareOwnershipRepairPlan ownerPlan = SmbShareRepair.PlanShareRootOwner(
    diagnostics.Shares[0],
    @"CONTOSO\File Admins");