TestimoX

API Reference

Class

SmbPermissions

Namespace ComputerX.Smb
Assembly ComputerX
Modifiers static

Convenience helpers for manipulating SMB share permissions (DACL) via WMI. Uses Win32_LogicalShareSecuritySetting.SetSecurityDescriptor under the hood.

Inheritance

  • Object
  • SmbPermissions

Methods

public static Boolean AddShareAllow(String computer, String shareName, String identity, SmbShareRights rights) #
Returns: Boolean

Adds an Allow ACE for an identity to a share (merge semantics).

Parameters

computer System.String requiredposition: 0
shareName System.String requiredposition: 1
identity System.String requiredposition: 2
rights ComputerX.Smb.SmbShareRights requiredposition: 3

Examples


SmbPermissions.AddShareAllow("SRV1", "Data", @"DOMAIN\\Ops", SmbShareRights.Change);
        
public static Boolean AddShareDeny(String computer, String shareName, String identity, SmbShareRights rights) #
Returns: Boolean

Adds a Deny ACE for an identity to a share (merge semantics).

Parameters

computer System.String requiredposition: 0
shareName System.String requiredposition: 1
identity System.String requiredposition: 2
rights ComputerX.Smb.SmbShareRights requiredposition: 3

Examples


SmbPermissions.AddShareDeny(null, "Data", @"DOMAIN\\Guests", SmbShareRights.FullControl);
        
public static Boolean AddSharePermission(String computer, String shareName, IEnumerable<String> identities, SmbShareRights rights, Boolean deny = false) #
Returns: Boolean

Adds Allow/Deny ACEs for multiple identities (merge semantics).

Parameters

computer System.String requiredposition: 0
shareName System.String requiredposition: 1
identities System.Collections.Generic.IEnumerable{System.String} requiredposition: 2
rights ComputerX.Smb.SmbShareRights requiredposition: 3
deny System.Boolean = false optionalposition: 4

Examples


SmbPermissions.AddSharePermission("SRV1", "Data", new[]{@"DOMAIN\\Ops", @"DOMAIN\\Auditors"}, SmbShareRights.Read);
        
public static Boolean RemoveSharePermission(String computer, String shareName, String identity, SmbShareRights rights, Boolean deny = false) #
Returns: Boolean

Removes specific rights from an identity on the share. When no bits remain, the ACE is removed.

Parameters

computer System.String requiredposition: 0
shareName System.String requiredposition: 1
identity System.String requiredposition: 2
rights ComputerX.Smb.SmbShareRights requiredposition: 3
deny System.Boolean = false optionalposition: 4

Examples


SmbPermissions.RemoveSharePermission("SRV1", "Data", @"DOMAIN\\Ops", SmbShareRights.Read);
        
public static Boolean SetSharePermission(String computer, String shareName, IEnumerable<String> identities, SmbShareRights rights, Boolean deny = false) #
Returns: Boolean

Replaces the share DACL with Allow/Deny ACEs for the provided identities (authoritative set).

Parameters

computer System.String requiredposition: 0
shareName System.String requiredposition: 1
identities System.Collections.Generic.IEnumerable{System.String} requiredposition: 2
rights ComputerX.Smb.SmbShareRights requiredposition: 3
deny System.Boolean = false optionalposition: 4

Examples


SmbPermissions.SetSharePermission(null, "Data", new[]{@"DOMAIN\\Ops"}, SmbShareRights.FullControl);