<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indented! &#187; permissions</title>
	<atom:link href="http://www.indented.co.uk/index.php/tag/permissions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indented.co.uk</link>
	<description></description>
	<lastBuildDate>Fri, 02 Jul 2010 10:45:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Reading share security with PowerShell</title>
		<link>http://www.indented.co.uk/index.php/2009/02/20/reading-share-security-with-powershell/</link>
		<comments>http://www.indented.co.uk/index.php/2009/02/20/reading-share-security-with-powershell/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 17:31:23 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[securitydescriptor]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=972</guid>
		<description><![CDATA[The cmdlet Get-ACL is very capable when it comes to NTFS permissions, but it cannot read share permissions. This function makes an effort to provide a simple way to return share security (and other information) from a share. The function makes use of two WMI Classes, Win32_Share and Win32_LogicalShareSecuritySetting. To simplify enumeration each Access Control [...]


Related posts:<ol><li><a href='http://www.indented.co.uk/index.php/2009/10/02/get-dsacl/' rel='bookmark' title='Permanent Link: Get-DsAcl'>Get-DsAcl</a> <small>The goal of this PowerShell function is to create a...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>The cmdlet Get-ACL is very capable when it comes to NTFS permissions, but it cannot read share permissions. This function makes an effort to provide a simple way to return share security (and other information) from a share.<br />
<span id="more-972"></span><br />
The function makes use of two WMI Classes, Win32_Share and Win32_LogicalShareSecuritySetting. To simplify enumeration each Access Control Entry found within the shares Discretionary Access Control List is converted to a FileSystemAccessRule before being added to the Access object, allowing the access to be displayed in a similar way to Access from Get-ACL.</p>
<p>Security information is only returned for shares of type 0, standard shared folders. Security for automatically generated administrative shares will not show. Access is added to the remainder of the information returned by Win32_Share. The Control Flags for the security descriptor are available, but not interesting as they are set to DiscretionaryAclPresent and SelfRelative.</p>
<p>The function accepts two parameters, the name of the share, and optionally the name of a computer. With no parameters, information for all shares on the computer is returned. WQL wildcards are supported (% and _) within the share name.</p>
<h4>Get-ShareACL</h4>
<pre class="brush: powershell;">
Function Get-ShareACL {
  Param(
    [String]$Name = &quot;%&quot;,
    [String]$Computer = $Env:ComputerName
  )

  $Shares = @()
  Get-WMIObject Win32_Share `
    -Computer $Computer -Filter &quot;Name LIKE '$Name'&quot; | `
    %{
      $Access = @();
      If ($_.Type -eq 0) {
        $SD = (Get-WMIObject -Class Win32_LogicalShareSecuritySetting `
          -Computer $Computer `
          -Filter &quot;Name='$($_.Name)'&quot;).GetSecurityDescriptor().Descriptor
        $SD.DACL | %{
          $Trustee = $_.Trustee.Name
          If ($_.Trustee.Domain -ne $Null) {
            $Trustee = &quot;$($_.Trustee.Domain)\$Trustee&quot;
          }
          $Access += New-Object Security.AccessControl.FileSystemAccessRule( `
            $Trustee, $_.AccessMask, $_.AceType)
        }
      }
      $_ | Select-Object Name, Path, Description, Caption, `
        @{n='Type';e={ Switch ($_.Type) {
          0 { &quot;Disk Drive&quot; }
          1 { &quot;Print Queue&quot; }
          2 { &quot;Device&quot; }
          2147483648 { &quot;Disk Drive Admin&quot; }
          2147483649 { &quot;Print Queue Admin&quot; }
          2147483650 { &quot;Device Admin&quot; }
          2147483651 { &quot;IPC Admin&quot; } }} }, `
        MaximumAllowed, AllowMaximum, Status, InstallDate, `
        @{n='Access';e={ $Access }}
  }
}
</pre>
<h4>Example</h4>
<pre class="brush: plain;">
PS C:\&gt; Get-ShareACL Test

Name           : Test
Path           : C:\Test
Description    :
Caption        : Test
Type           : Disk Drive
MaximumAllowed :
AllowMaximum   : True
Status         : OK
InstallDate    :
Access         : {System.Security.AccessControl.FileSystemAccessRule}

PS C:\&gt; (Get-ShareACL Test).Access

FileSystemRights  : ReadAndExecute
AccessControlType : Allow
IdentityReference : somedomain\chrisdent
IsInherited       : False
InheritanceFlags  : None
PropagationFlags  : None
</pre>


<p>Related posts:<ol><li><a href='http://www.indented.co.uk/index.php/2009/10/02/get-dsacl/' rel='bookmark' title='Permanent Link: Get-DsAcl'>Get-DsAcl</a> <small>The goal of this PowerShell function is to create a...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2009/02/20/reading-share-security-with-powershell/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Reading NTFS and Share security with VbScript</title>
		<link>http://www.indented.co.uk/index.php/2009/02/19/reading-ntfs-and-share-security-with-vbscript/</link>
		<comments>http://www.indented.co.uk/index.php/2009/02/19/reading-ntfs-and-share-security-with-vbscript/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 17:25:25 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[VbScript]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[ntfs]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[securitydescriptor]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=908</guid>
		<description><![CDATA[NTFS (File System) and Share security can be enumerated using the Win32_LogicalFileSecuritySetting and Win32_LogicalShareSecuritySetting WMI classes. This post demonstrates how to use each class to read the security descriptors. In each case the WMI class contains a GetSecurityDescriptor method used to retrieve the Security Descriptor (as a Win32_SecurityDescriptor). The references section at the bottom of [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>NTFS (File System) and Share security can be enumerated using the Win32_LogicalFileSecuritySetting and Win32_LogicalShareSecuritySetting WMI classes. This post demonstrates how to use each class to read the security descriptors.<br />
<span id="more-908"></span><br />
In each case the WMI class contains a GetSecurityDescriptor method used to retrieve the Security Descriptor (as a Win32_SecurityDescriptor).</p>
<p>The references section at the bottom of this article include details of sources for all constants. A little PowerShell creeps in to show how the numeric values were retrieved and checked.</p>
<h3>DACLs and SACLs</h3>
<p>A DACL or Discretionary Access Control List is the most heavily used, it contains Access Control Entries that define who can, and who cannot, access a resource or object. These are seen when viewing the Security tab of an object.</p>
<p>An SACL or System Access Control List defines which actions will be audited when accessing an a resource or object. Seen by accessing the Audit tab through Security and Advanced.</p>
<h3>NTFS security vs Share security</h3>
<p>Both the NTFS and the Share security descriptor can be read in exactly the same way. However, there are important differences between them.</p>
<h4>NTFS security descriptor</h4>
<ul>
<li>Supports inheritance on descriptor and on individual Access Control Entries</li>
<li>Can hold a Discretionary Access Control List and an System Access Control List</li>
</ul>
<h4>Share security descriptor</h4>
<ul>
<li>Has no owner or Primary Group</li>
<li>Control flags will be set (and usually limited) to SelfRelative and DiscretionaryACLPresent</li>
<li>Access Control Entry (ACE) Flags will not be set</li>
<li>Can hold a Discretionary Access Control List only</li>
<li>Supports a sub-set of Access Masks (rights) on each ACE</li>
</ul>
<h3>Getting the security descriptor</h3>
<h4>NTFS</h4>
<pre class="brush: vb;">
Dim strComputer : strComputer = &quot;.&quot;
' Connect to WMI on strComputer
Dim objWMI : Set objWMI = GetObject(&quot;winmgmts://&quot; &amp; strComputer &amp; &quot;/root/cimv2&quot;)
' Get an instance of LogicalFileSecuritySetting for C:\
Dim objSecuritySettings : Set objSecuritySettings = _
  objWMI.Get(&quot;Win32_LogicalFileSecuritySetting='C:\'&quot;)
Dim intReturnValue : Dim objSD
' Request the Security Descriptor as objSD
intReturnValue = objSecuritySettings.GetSecurityDescriptor objSD
</pre>
<h4>Share</h4>
<pre class="brush: vb;">
Dim strComputer : strComputer = &quot;.&quot;
' Connect to WMI on strComputer
Dim objWMI : Set objWMI = GetObject(&quot;winmgmts://&quot; &amp; strComputer &amp; &quot;/root/cimv2&quot;)
' Get an instance of LogicalShareSecuritySetting for ShareName
Dim objSecuritySettings : Set objSecuritySettings = _
  objWMI.Get(&quot;Win32_LogicalShareSecuritySetting='ShareName'&quot;)
Dim intReturnValue : Dim objSD
' Request the Security Descriptor as objSD
intReturnValue = objSecuritySettings.GetSecurityDescriptor objSD
</pre>
<h4>Error handling</h4>
<p>The GetSecurityDescriptor method of each WMI class (Win32_LogicalFileSecuritySetting and Win32_LogicalShareSecuritySetting) has a return value to allow errors to be handled. The return codes are represented by the constants below.</p>
<pre class="brush: vb;">
Const SUCCESS = 0
Const ACCESS_DENIED = 2
Const UNKNOWN_FAILURE = 8
Const PRIVILEGE_MISSING = 9
Const INVALID_PARAMETER = 21
</pre>
<h3>Values in the security descriptor</h3>
<p>The security descriptor contains three fields in addition to the DACL and SACL which are described later.</p>
<h4>Control flags</h4>
<p>Each security descriptor has a ControlFlags field which dictates how the descriptor behaves. This includes settings such as DACLProtected which indicates that the DACL cannot inherit values from a parent.</p>
<p>The script loads the values above into a Scripting.Dictionary object to simplify enumeration.</p>
<pre class="brush: vb;">
Dim objControlFlags : Set objControlFlags = CreateObject(&quot;Scripting.Dictionary&quot;)
objControlFlags.Add 32768, &quot;SelfRelative&quot;
objControlFlags.Add 16384, &quot;RMControlValid&quot;
objControlFlags.Add 8192, &quot;SystemAclProtected&quot;
objControlFlags.Add 4096, &quot;DiscretionaryAclProtected&quot;
objControlFlags.Add 2048, &quot;SystemAclAutoInherited&quot;
objControlFlags.Add 1024, &quot;DiscretionaryAclAutoInherited&quot;
objControlFlags.Add 512, &quot;SystemAclAutoInheritRequired&quot;
objControlFlags.Add 256, &quot;DiscretionaryAclAutoInheritRequired&quot;
objControlFlags.Add 32, &quot;SystemAclDefaulted&quot;
objControlFlags.Add 16, &quot;SystemAclPresent&quot;
objControlFlags.Add 8, &quot;DiscretionaryAclDefaulted&quot;
objControlFlags.Add 4, &quot;DiscretionaryAclPresent&quot;
objControlFlags.Add 2, &quot;GroupDefaulted&quot;
objControlFlags.Add 1, &quot;OwnerDefaulted&quot;
</pre>
<p>Note that they are intentionally entered in order from highest to lowest. A For Each loop will start with the highest value (because it was added first), then compare it to the ControlFlags value. In bitwise comparison, if the integer value can be there, then it must be there, that would all go wrong unless it starts with the highest possible value.</p>
<p>The values and names were taken from the .NET Framework, they can be displayed in PowerShell with the following command.</p>
<pre class="brush: powershell;">
[Enum]::GetValues([System.Security.AccessControl.ControlFlags]) | `
  Select-Object @{ n='Name';e={[String]$_} }, @{ n='Value';e={$_.value__} }
</pre>
<p>That logic is applied within the code as follows.</p>
<pre class="brush: vb;">
' Read the value of Control Flags from the descriptor
dblControlFlags = objSD.ControlFlags
WScript.Echo &quot;Control Flags:&quot;
' For each possible flag
For Each dblFlag in objControlFlags
  ' If it is possible for the flag to be there, then it must be there
  ' Something like bitwise AND
  If dblControlFlags &gt;= dblFlag Then
    ' Echo the flag, indicating it is present
    WScript.Echo &quot;  &quot; &amp; objControlFlags(dblFlag)
    ' Remove this value from the control flag value,
    ' already found this flag
    dblControlFlags = dblControlFlags - dblFlag
  End If
Next
</pre>
<h4>Primary group</h4>
<p>The Primary Group is not very interesting unless Services for Unix is in use. In many cases it will be blank.</p>
<p>If set, it can be enumerated as a Win32_Trustee, an object containing a Domain, Username, SID array, SID length and SIDString.</p>
<h4>Owner</h4>
<p>As with the Primary Group, the owner is stored as a Win32_Trustee object. It can be read from the descriptor as follows.</p>
<pre class="brush: vb;">
WScript.Echo &quot;Domain: &quot; &amp; objSD.Owner.Domain
WScript.Echo &quot;Username: &quot; &amp; objSD.Owner.Name
WScript.Echo &quot;SID: &quot; &amp; objSD.Owner.SIDString
</pre>
<h3>Access control entries in the DACL and SACL</h3>
<p>Both the DACL and SACL, if present, consist of one or more Access Control Entries (ACE). The ACE, like the security descriptor, breaks down into a number of different fields.</p>
<h4>Access Mask</h4>
<p>The access mask defines which rights should be used by the Access Control Entry. In the case of System ACL it defines which actions should be audited.</p>
<p>A number of the right names are omitted from the list below as they carry the same numeric value (mask the same bit), the meaning only changes in the context the right is applied.</p>
<pre class="brush: vb;">
Dim objAccessRights : Set objAccessRights = CreateObject(&quot;Scripting.Dictionary&quot;)
objAccessRights.Add 2032127, &quot;FullControl&quot;
objAccessRights.Add 1048576, &quot;Synchronize&quot;
objAccessRights.Add 524288, &quot;TakeOwnership&quot;
objAccessRights.Add 262144, &quot;ChangePermissions&quot;
objAccessRights.Add 197055, &quot;Modify&quot;
objAccessRights.Add 131241, &quot;ReadAndExecute&quot;
objAccessRights.Add 131209, &quot;Read&quot;
objAccessRights.Add 131072, &quot;ReadPermissions&quot;
objAccessRights.Add 65536, &quot;Delete&quot;
objAccessRights.Add 278, &quot;Write&quot;
objAccessRights.Add 256, &quot;WriteAttributes&quot;
objAccessRights.Add 128, &quot;ReadAttributes&quot;
objAccessRights.Add 64, &quot;DeleteSubdirectoriesAndFiles&quot;
objAccessRights.Add 32, &quot;ExecuteFile&quot;
objAccessRights.Add 16, &quot;WriteExtendedAttributes&quot;
objAccessRights.Add 8, &quot;ReadExtendedAttributes&quot;
objAccessRights.Add 4, &quot;AppendData&quot;
objAccessRights.Add 2, &quot;CreateFiles&quot;
objAccessRights.Add 1, &quot;ReadData&quot;
</pre>
<p>Note that a number of the rights in the list are composites of simpler rights, including Read, FullControl, Write and Modify.</p>
<p>The list can be retrieved, using PowerShell again, with the following command:</p>
<pre class="brush: powershell;">
[Enum]::GetValues([System.Security.AccessControl.FileSystemRights]) | `
  Select-Object @{n='Name';e={[String]$_} }, @{n='Value';e={$_.value__} }
</pre>
<p>Holding the flags in this fashion allows the Access Mask to be converted to a friendly form in the same way as the Control Flags were displayed.</p>
<pre class="brush: vb;">
' For each access control entry in the discretionary access control list
For Each objACE in objSD.DACL
  WScript.Echo &quot;Access Mask:&quot;
  ' Read the value of the access mask from the Access Control Entry
  dblAccessMask = objACE.AccessMask
  ' For each possible Right
  For Each dblAccess in objAccessRights
    ' If the right can be there then it must...
    If dblAccessMask &gt;= dblAccess Then
      ' Echo the right name
      WScript.Echo &quot;  &quot; &amp; objAccessRights(dblAccess)
      ' Remove the value from the access mask,
      ' already found this right.
      dblAccessMask = dblAccessMask - dblAccess
    End If
  Next
Next
</pre>
<h4>Flags</h4>
<p>The flags on an Access Control Entry defines whether the entry applies to Leaf or Container objects, how it behaves when inheritance is calculated, and whether or not the ACE is inherited or explicit.</p>
<pre class="brush: vb;">
Dim objAceFlags : Set objAceFlags = CreateObject(&quot;Scripting.Dictionary&quot;)
objAceFlags.Add 128, &quot;FailedAccess&quot;
objAceFlags.Add 64, &quot;SuccessfulAccess&quot;
objAceFlags.Add 16, &quot;Inherited&quot;
objAceFlags.Add 8, &quot;InheritOnly&quot;
objAceFlags.Add 4, &quot;NoPropagateInherit&quot;
objAceFlags.Add 2, &quot;ContainerInherit&quot;
objAceFlags.Add 1, &quot;ObjectInherit&quot;
</pre>
<p>Heading back to PowerShell again we can find the the names and values for these.</p>
<pre class="brush: powershell;">
[Enum]::GetValues([System.Security.AccessControl.AceFlags]) | `
  Select-Object @{n='Name';e={[String]$_} }, @{n='Value';e={$_.value__} }
</pre>
<p>A few are intentionally left out as they are composites of values more interesting to display separately.</p>
<p>Enumeration of the Access Control Entry flags is performed as follows.</p>
<pre class="brush: vb;">
' For each access control entry in the discretionary access control list
For Each objACE in objSD.DACL
  WScript.Echo &quot;ACE Flags:&quot;
    ' Read the value of ACE Flags from the Access Control Entry
  dblAceFlags = objAce.AceFlags
  ' For each possible flag
  For Each dblFlag in objAceFlags
    ' If the flag can be there then it must...
    If dblAceFlags &gt;= dblFlag Then
      ' Echo the name of the flag
      WScript.Echo &quot;  &quot; &amp; objAceFlags(dblFlag)
      ' Found it, remove it to note that it has been found.
      dblAceFlags = dblAceFlags - dblFlag
    End If
  Next
Next
</pre>
<h4>Trustee</h4>
<p>The value for the trustee (Win32_Trustee), the security principal (user, group, computer, etc) the right applies to is enumerated in the same way as the Owner above.</p>
<pre class="brush: vb;">
For Each objACE in objDACL
  WScript.Echo &quot;Domain: &quot; &amp; objACE.Trustee.Domain
  WScript.Echo &quot;User: &quot; &amp; objACE.Trustee.Name
  WScript.Echo &quot;SID: &quot; &amp; objACE.Trustee.SIDString
Next
</pre>
<h4>Type</h4>
<p>Finally, the ACEType consists of three values which define whether the ACE permits access, denies access or is an audit control.</p>
<pre class="brush: vb;">
Dim objAceTypes : Set objAceTypes = CreateObject(&quot;Scripting.Dictionary&quot;)
objAceTypes.Add 0, &quot;Allow&quot;
objAceTypes.Add 1, &quot;Deny&quot;
objAceTypes.Add 2, &quot;Audit&quot;
</pre>
<p>Once again, we can discover all of the possible values for AceFlags using PowerShell.</p>
<pre class="brush: powershell;">
[Enum]::GetValues([System.Security.AccessControl.AceType]) | `
  Select-Object @{n='Name';e={[String]$_} }, @{n='Value';e={$_.value__} }
</pre>
<p>However, this time the only values that are used in the script are 0 (Allow), 1 (Deny), and 2 (Audit).</p>
<pre class="brush: vb;">
' For each access control entry in the discretionary access control list
For Each objACE in objDACL
  ' Echo the type: Allow, Deny or Audit.
  WScript.Echo &quot;ACE Type: &quot; &amp; objAceTypes(objAce.AceType)
Next
</pre>
<h3>Listing permissions for all Shares</h3>
<p>Time to put all of that together. This sample lists the NTFS and Share permissions for each share configured on strComputer.</p>
<pre class="brush: vb;">
Option Explicit

' WMI Constants

Const WBEM_RETURN_IMMEDIATELY = &amp;h10
Const WBEM_FORWARD_ONLY = &amp;h20

' Constants and storage arrays for security settings

' GetSecurityDescriptor Return values

Dim objReturnCodes : Set objReturnCodes = CreateObject(&quot;Scripting.Dictionary&quot;)
Const SUCCESS = 0
Const ACCESS_DENIED = 2
Const UNKNOWN_FAILURE = 8
Const PRIVILEGE_MISSING = 9
Const INVALID_PARAMETER = 21

' Security Descriptor Control Flags

Dim objControlFlags : Set objControlFlags = CreateObject(&quot;Scripting.Dictionary&quot;)
objControlFlags.Add 32768, &quot;SelfRelative&quot;
objControlFlags.Add 16384, &quot;RMControlValid&quot;
objControlFlags.Add 8192, &quot;SystemAclProtected&quot;
objControlFlags.Add 4096, &quot;DiscretionaryAclProtected&quot;
objControlFlags.Add 2048, &quot;SystemAclAutoInherited&quot;
objControlFlags.Add 1024, &quot;DiscretionaryAclAutoInherited&quot;
objControlFlags.Add 512, &quot;SystemAclAutoInheritRequired&quot;
objControlFlags.Add 256, &quot;DiscretionaryAclAutoInheritRequired&quot;
objControlFlags.Add 32, &quot;SystemAclDefaulted&quot;
objControlFlags.Add 16, &quot;SystemAclPresent&quot;
objControlFlags.Add 8, &quot;DiscretionaryAclDefaulted&quot;
objControlFlags.Add 4, &quot;DiscretionaryAclPresent&quot;
objControlFlags.Add 2, &quot;GroupDefaulted&quot;
objControlFlags.Add 1, &quot;OwnerDefaulted&quot;

' ACE Access Right

Dim objAccessRights : Set objAccessRights = CreateObject(&quot;Scripting.Dictionary&quot;)
objAccessRights.Add 2032127, &quot;FullControl&quot;
objAccessRights.Add 1048576, &quot;Synchronize&quot;
objAccessRights.Add 524288, &quot;TakeOwnership&quot;
objAccessRights.Add 262144, &quot;ChangePermissions&quot;
objAccessRights.Add 197055, &quot;Modify&quot;
objAccessRights.Add 131241, &quot;ReadAndExecute&quot;
objAccessRights.Add 131209, &quot;Read&quot;
objAccessRights.Add 131072, &quot;ReadPermissions&quot;
objAccessRights.Add 65536, &quot;Delete&quot;
objAccessRights.Add 278, &quot;Write&quot;
objAccessRights.Add 256, &quot;WriteAttributes&quot;
objAccessRights.Add 128, &quot;ReadAttributes&quot;
objAccessRights.Add 64, &quot;DeleteSubdirectoriesAndFiles&quot;
objAccessRights.Add 32, &quot;ExecuteFile&quot;
objAccessRights.Add 16, &quot;WriteExtendedAttributes&quot;
objAccessRights.Add 8, &quot;ReadExtendedAttributes&quot;
objAccessRights.Add 4, &quot;AppendData&quot;
objAccessRights.Add 2, &quot;CreateFiles&quot;
objAccessRights.Add 1, &quot;ReadData&quot;

' ACE Types

Dim objAceTypes : Set objAceTypes = CreateObject(&quot;Scripting.Dictionary&quot;)
objAceTypes.Add 0, &quot;Allow&quot;
objAceTypes.Add 1, &quot;Deny&quot;
objAceTypes.Add 2, &quot;Audit&quot;

' ACE Flags

Dim objAceFlags : Set objAceFlags = CreateObject(&quot;Scripting.Dictionary&quot;)
objAceFlags.Add 128, &quot;FailedAccess&quot;
objAceFlags.Add 64, &quot;SuccessfulAccess&quot;
objAceFlags.Add 16, &quot;Inherited&quot;
objAceFlags.Add 8, &quot;InheritOnly&quot;
objAceFlags.Add 4, &quot;NoPropagateInherit&quot;
objAceFlags.Add 2, &quot;ContainerInherit&quot;
objAceFlags.Add 1, &quot;ObjectInherit&quot;

Sub ReadNTFSSecurity(objWMI, strPath)
  WScript.Echo &quot;  Displaying NTFS Security&quot;

  Dim objSecuritySettings : Set objSecuritySettings = _
    objWMI.Get(&quot;Win32_LogicalFileSecuritySetting='&quot; &amp; strPath &amp; &quot;'&quot;)
  Dim objSD : objSecuritySettings.GetSecurityDescriptor objSD

  Dim strDomain : strDomain = objSD.Owner.Domain
  If strDomain &lt;&gt; &quot;&quot; Then strDomain = strDomain &amp; &quot;\&quot;
  WScript.Echo &quot;  Owner: &quot; &amp; strDomain &amp; objSD.Owner.Name
  WScript.Echo &quot;  Owner SID: &quot; &amp; objSD.Owner.SIDString

  WScript.Echo &quot;  Basic Control Flags Value: &quot; &amp; objSD.ControlFlags
  WScript.Echo &quot;  Control Flags:&quot;

  DisplayValues objSD.ControlFlags, objControlFlags

  WScript.Echo

  Dim objACE

  ' Display the DACL

  WScript.Echo &quot;  Discretionary Access Control List:&quot;
  For Each objACE in objSD.DACL
    DisplayACE objACE
  Next

  ' Display the SACL (if there is one)

  If Not IsNull(objSD.SACL) Then
    WScript.Echo &quot;  System Access Control List:&quot;
    For Each objACE in objSD.SACL
      DisplayACE objACE
    Next
  End If
End Sub

Sub ReadShareSecurity(objWMI, strName)
  WScript.Echo &quot;  Displaying Share Security&quot;

  Dim objSecuritySettings : Set objSecuritySettings = _
    objWMI.Get(&quot;Win32_LogicalShareSecuritySetting='&quot; &amp; strName &amp; &quot;'&quot;)

  Dim objSD : objSecuritySettings.GetSecurityDescriptor objSD

  WScript.Echo &quot;  Basic Control Flags Value: &quot; &amp; objSD.ControlFlags
  WScript.Echo &quot;  Control Flags:&quot;

  DisplayValues objSD.ControlFlags, objControlFlags

  WScript.Echo

  Dim objACE

  ' Display the DACL

  WScript.Echo &quot;  Discretionary Access Control List:&quot;
  For Each objACE in objSD.DACL
    DisplayACE objACE
  Next
End Sub

Sub DisplayValues(dblValues, objSecurityEnumeration)

  Dim dblValue
  For Each dblValue in objSecurityEnumeration
    If dblValues &gt;= dblValue Then
      WScript.Echo &quot;      &quot; &amp; objSecurityEnumeration(dblValue)
      dblValues = dblValues - dblValue
    End If
  Next
End Sub

Sub DisplayACE(objACE)

  Dim strDomain : strDomain = objAce.Trustee.Domain
  If strDomain &lt;&gt; &quot;&quot; Then strDomain = strDomain &amp; &quot;\&quot;
  WScript.Echo &quot;    Trustee: &quot; &amp; UCase(strDomain &amp; objAce.Trustee.Name)
  WScript.Echo &quot;    SID: &quot; &amp; objAce.Trustee.SIDString

  WScript.Echo &quot;    Basic Access Mask Value: &quot; &amp; objACE.AccessMask

  WScript.Echo &quot;    Access Rights: &quot;
  DisplayValues objACE.AccessMask, objAccessRights

  WScript.Echo &quot;    Type: &quot; &amp; objAceTypes(objACE.AceType)

  WScript.Echo &quot;    Basic ACE Flags Value: &quot; &amp; objACE.AceFlags

  WScript.Echo &quot;    ACE Flags: &quot;
  DisplayValues objACE.AceFlags, objAceFlags
  WScript.Echo
End Sub

'
' Main Code
'

' The system to execute this script against
Dim strComputer : strComputer = &quot;.&quot;

' Connect to WMI
Dim objWMI : Set objWMI = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;)

' Return all of the shares (Type = 0 means File Shares only, exclude
' are Administrative, Printer, etc)
Dim colItems : Set colItems = _
  objWMI.ExecQuery(&quot;SELECT * FROM Win32_Share WHERE Type='0'&quot;, &quot;WQL&quot;, _
  WBEM_RETURN_IMMEDIATELY + WBEM_FORWARD_ONLY)

Dim objItem
For Each objItem in colItems
  WScript.Echo
  WScript.Echo &quot;Security for &quot; &amp; objItem.Path &amp; _
    &quot; (Shared as &quot; &amp; objItem.Name &amp; &quot;)&quot;

  ReadNTFSSecurity objWMI, objItem.Path
  ReadShareSecurity objWMI, objItem.Name
Next
</pre>
<h4>References</h4>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa394180(VS.85).aspx">Win32_LogicalFileSecuritySetting</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa394188(VS.85).aspx">Win32_LogicalShareSecuritySetting</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa394402(VS.85).aspx">Win32_SecurityDescriptor</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa394063(VS.85).aspx">Win32_ACE</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa394501(VS.85).aspx">Win32_Trustee</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.controlflags.aspx">ControlFlags Enumeration</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesystemrights.aspx">FileSystemRights Enumeration</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.aceflags.aspx">AceFlags Enumeration</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.acetype.aspx">AceType Enumeration</a></li>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2009/02/19/reading-ntfs-and-share-security-with-vbscript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Finding a user in Exchange mailbox security</title>
		<link>http://www.indented.co.uk/index.php/2008/10/28/exchange-2003-finding-a-user-in-mailbox-security/</link>
		<comments>http://www.indented.co.uk/index.php/2008/10/28/exchange-2003-finding-a-user-in-mailbox-security/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 11:33:59 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[VbScript]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[securitydescriptor]]></category>
		<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=575</guid>
		<description><![CDATA[A script to read the mailbox security descriptor from Active Directory with the intention of finding a particular user or security principal. It will not display the security descriptor, it simply displays whether or not the account is present in the access control list. The script works best when run with cscript as the script [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>A script to read the mailbox security descriptor from Active Directory with the intention of finding a particular user or security principal. It will not display the security descriptor, it simply displays whether or not the account is present in the access control list.<br />
<span id="more-575"></span><br />
The script works best when run with cscript as the script uses WScript.Echo to write back whether or not it finds a match.</p>
<p>It can be used against Exchange 2000 or Exchange 2003. Exchange 2007 can use Get-MailboxPermission to query the same information.</p>
<p>MailboxRights is used to retrieve the mailbox security descriptor. As part of CDOEXM (Collaboration Data Objects for Exchange Management) the Exchange System Tools must be installed on the system executing the script.</p>
<pre class="brush: vb;">
Option Explicit

' FindMailboxAccess.vbs
'
' Short Script to Find and Enumerate Mailbox Access for the specified
' security principal. Searches current domain, must be run as an Exchange Admin
' account to invoke MailboxRights method.
'
' This script is slow, it's speed is unavoidable as MailboxRights cannot be
' executed until connected to an individual user. That means we have to connect
' to every user account to determine whether or not the security principal is
' present within the ACL.
'
' Author: Chris Dent
' Modified: 04/01/2008

Sub UsageText
  Dim strMessage

  strMessage = &quot;Usage:&quot; &amp; VbCrLf &amp; VbCrLf
  strMessage = strMessage &amp; &quot;cscript &quot; &amp; WScript.ScriptName &amp; _
    &quot; &lt;search String&gt;&quot; &amp; VbCrLf
  strMessage = strmessage &amp; VbCrLf
  strMessage = strMessage &amp; &quot;Note: This script must be executed as Exchange &quot; &amp; _
    &quot;Administrator to enumerate&quot; &amp; VbCrLf
  strMessage = strMessage &amp; &quot;the Mailbox Security Descriptor&quot; &amp; VbCrLf
  WScript.Echo strMessage
  WScript.Quit
End Sub

Sub SortArgv
  Dim objArgv

  Set objArgv = WScript.Arguments
  If objArgv.Count &lt; 1 Then
    UsageText
  End If

  strSearchString = objArgv(0)

  Set objArgv = Nothing
End Sub

Sub SearchAD
  Const ADS_SCOPE_SUBTREE = 2

  Dim objConnection, objCommand, objRootDSE, objRecordSet, objUser
  Dim objMailboxSD, objDACL, objACE

  Set objConnection = CreateObject(&quot;ADODB.Connection&quot;)
  objConnection.Provider = &quot;ADsDSOObject&quot;
  objConnection.Open &quot;Active Directory Provider&quot;

  Set objCommand = CreateObject(&quot;ADODB.Command&quot;)
  objCommand.ActiveConnection = objConnection

  Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
  objCommand.CommandText = &quot;SELECT distinguishedName, homeMDB &quot; &amp;_
    &quot;FROM 'LDAP://&quot; &amp; objRootDSE.Get(&quot;defaultNamingContext&quot;) &amp;_
    &quot;' WHERE objectClass='user' AND objectCategory='person'&quot;
  WScript.Echo &quot;Searching: &quot; &amp; objRootDSE.Get(&quot;defaultNamingContext&quot;)
  Set objRootDSE = Nothing

  objCommand.Properties(&quot;Page Size&quot;) = 1000
  objCommand.Properties(&quot;Timeout&quot;) = 600
  objCommand.Properties(&quot;Searchscope&quot;) = ADS_SCOPE_SUBTREE
  objCommand.Properties(&quot;Cache Results&quot;) = False

  Set objRecordSet = objCommand.Execute

  While Not objRecordSet.EOF
    On Error Resume Next
    If Not IsNull(objRecordSet.Fields(&quot;homeMDB&quot;)) Then
      ' Can't avoid connecting to the user, need to call the MailboxRights method

      Set objUser = _
        GetObject(&quot;LDAP://&quot; &amp; objRecordSet.Fields(&quot;distinguishedName&quot;).Value)

      Err.Clear
      Set objMailboxSD = objUser.MailboxRights
      Set objDACL = objMailboxSD.DiscretionaryAcl
      If Err.Number &lt;&gt; 0 Then
        ' Ignore It
      Else
        For Each objACE in objDACL
          If InStr(1, objACE.Trustee, strSearchString, VbTextCompare) Then
            WScript.Echo &quot;Found In Mailbox ACL: &quot; &amp; objUser.Name
          End If
        Next
      End If
      On Error Goto 0
    End If

    objRecordSet.MoveNext
  Wend
  objConnection.Close

  Set objRecordSet = Nothing
  Set objCommand = Nothing
  Set objConnection = Nothing
End Sub

'
' Main Code
'

Dim strSearchString

SortArgv

WScript.Echo &quot;Search String: &quot; &amp; strSearchString

SearchAD
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2008/10/28/exchange-2003-finding-a-user-in-mailbox-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NTFS, WMI, VbScript &amp; listing explicit rights</title>
		<link>http://www.indented.co.uk/index.php/2008/10/22/listing-explicit-rights/</link>
		<comments>http://www.indented.co.uk/index.php/2008/10/22/listing-explicit-rights/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 15:04:02 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[VbScript]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[ntfs]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[securitydescriptor]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=423</guid>
		<description><![CDATA[This script uses WMI to enumerate each access control entry in an NTFS access control list, looking for explicit entries, that is, entries that are not inherited. If SECURITY_PRINCIPAL is blank the script will return all explicit rights beneath granted from base path down. The script attempts to provide a summary for common rights. The [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This script uses WMI to enumerate each access control entry in an NTFS access control list, looking for explicit entries, that is, entries that are not inherited.<br />
<span id="more-423"></span><br />
If SECURITY_PRINCIPAL is blank the script will return all explicit rights beneath granted from base path down. The script attempts to provide a summary for common rights.</p>
<p>The PowerShell version of this script is considerably better for granular reporting of rights assigned. This one is more of a demonstration of security descriptor enumeration.</p>
<pre class="brush: vb;">
Option Explicit

' Looks for a Trustee containing the SECURITY_PRINCIPAL string on
' the file system. Recurses from BASE_PATH down (file and folders).

' Set these values for the search.

Const BASE_PATH = &quot;C:\&quot;
Const SECURITY_PRINCIPAL = &quot;Chris&quot;

Sub FSRecurse(strPath)
  ' Simple FS recursion

  Dim objFolder, objFile, objSubFolder

  Set objFolder = objFileSystem.GetFolder(strPath)

  For Each objFile in objFolder.Files
    CheckDescriptor objFile.Path
  Next
  For Each objSubFolder in objFolder.SubFolders
    CheckDescriptor objSubFolder.Path

    FSRecurse objSubFolder.Path
  Next

  Set objFolder = Nothing
End Sub

Sub CheckDescriptor(strPath)
  ' Look for the Trustee in the Security Descriptor and filter out
  ' inherited ACEs

  Const ACE_FLAG_INHERITED = &amp;H10 ' 16

  Dim objSecuritySettings, objSecurityDescriptor, objACE, objTrustee

  Set objSecuritySettings = objWMIService.Get _
    (&quot;Win32_LogicalFileSecuritySetting.Path='&quot; &amp; strPath &amp; &quot;'&quot;)
  objSecuritySettings.GetSecurityDescriptor objSecurityDescriptor

  For Each objACE in objSecurityDescriptor.dACL
    If InStr(1, objACE.Trustee.Name, _
        SECURITY_PRINCIPAL, VbTextCompare) &gt; 0 Then

      ' ACEFlags is binary. Must perform binary comparison.
      If objACE.ACEFlags And ACE_FLAG_INHERITED Then
        ' Problems with negation of the above.
        ' This is just easier.
      Else
        EnumAccess strPath, objACE
      End If
    End If
  Next
End Sub

Sub EnumAccess(strPath, objACE)
  ' Most access mask values have matching Folder versions. These are not
  ' numerically different, they only differ when interpreted.

  ' ACE Type

  Const ACCESS_ALLOWED_ACE_TYPE = &amp;h0
  Const ACCESS_DENIED_ACE_TYPE  = &amp;h1

  ' Base Access Mask values

  Const FILE_READ_DATA = &amp;h1
  Const FILE_WRITE_DATA = &amp;h2
  Const FILE_APPEND_DATA = &amp;h4
  Const FILE_READ_EA = &amp;h8
  Const FILE_WRITE_EA = &amp;h10
  Const FILE_EXECUTE = &amp;h20
  Const FILE_DELETE_CHILD = &amp;h40
  Const FILE_READ_ATTRIBUTES = &amp;h80
  Const FILE_WRITE_ATTRIBUTES = &amp;h100
  Const FOLDER_DELETE = &amp;h10000
  Const READ_CONTROL = &amp;h20000
  Const WRITE_DAC = &amp;h40000
  Const WRITE_OWNER = &amp;h80000
  Const SYNCHRONIZE = &amp;h100000

  ' Constructed Access Masks

  Dim FULL_CONTROL
  FULL_CONTROL = FILE_READ_DATA + FILE_WRITE_DATA + FILE_APPEND_DATA + _
    FILE_READ_EA + FILE_WRITE_EA + FILE_EXECUTE + FILE_DELETE_CHILD + _
    FILE_READ_ATTRIBUTES + FILE_WRITE_ATTRIBUTES + FOLDER_DELETE + _
    READ_CONTROL + WRITE_DAC + WRITE_OWNER + SYNCHRONIZE

  Dim READ_ONLY
  READ_ONLY = FILE_READ_DATA + FILE_READ_EA + FILE_EXECUTE + _
    FILE_READ_ATTRIBUTES + READ_CONTROL + SYNCHRONIZE

  Dim MODIFY
  MODIFY = FILE_READ_DATA + FILE_WRITE_DATA + FILE_APPEND_DATA + _
    FILE_READ_EA + FILE_WRITE_EA + FILE_EXECUTE + _
    FILE_READ_ATTRIBUTES + _
    FILE_WRITE_ATTRIBUTES + FOLDER_DELETE + READ_CONTROL + SYNCHRONIZE

  Dim strRights
  Dim intAccessMask

  WScript.Echo &quot;Path: &quot; &amp; strPath
  WScript.Echo &quot;Username: &quot; &amp; objACE.Trustee.Name
  WScript.Echo &quot;Domain: &quot; &amp; objACE.Trustee.Domain
  WScript.Echo &quot;ACE Flags (Decimal): &quot; &amp; objACE.ACEFlags

  ' ACE Type

  If objACE.ACEType = ACCESS_ALLOWED_ACE_TYPE Then
    WScript.Echo &quot;ACE Type: Allow&quot;
  Else
    WScript.Echo &quot;ACE Type: Deny&quot;
  End If

  ' Attempt to generate a basic summary of access rights

  strRights = &quot;&quot;
  intAccessMask = objACE.AccessMask

  If intAccessMask = FULL_CONTROL Then
    strRights = &quot; (FullControl)&quot;
  ElseIf intAccessMask = MODIFY Then

    strRights = &quot; (Modify)&quot;
  ElseIf intAccessMask = READ_ONLY Then
    strRights = &quot; (ReadOnly)&quot;
  End If

  ' Echo the decimal mask with any summarised rights

  WScript.Echo &quot;Access Mask (Decimal): &quot; &amp; intAccessMask &amp; strRights

  WScript.Echo
End Sub

'
' Main code block
'

Dim objFileSystem, objWMIService

Set objFileSystem = CreateObject(&quot;Scripting.FileSystemObject&quot;)
' WMI Connection to the local machine
Set objWMIService = GetObject(&quot;winmgmts:\\.&quot;)

FSRecurse BASE_PATH

Set objWMIService = Nothing
Set objFileSystem = Nothing
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2008/10/22/listing-explicit-rights/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NTFS, PowerShell, Get-ACL &amp; listing explicit rights</title>
		<link>http://www.indented.co.uk/index.php/2008/10/22/powershell-get-acl-listing-explicit-rights/</link>
		<comments>http://www.indented.co.uk/index.php/2008/10/22/powershell-get-acl-listing-explicit-rights/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 11:50:56 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[acl]]></category>
		<category><![CDATA[ntfs]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[securitydescriptor]]></category>

		<guid isPermaLink="false">http://www.highorbit.co.uk/?p=395</guid>
		<description><![CDATA[A short script to list explicit rights assigned to a directory structure. It uses the recursive option of ls (an Alias for Get-ChildItem) to drop down through the directory structure. There are lots of little programs around that can do exactly the same thing, probably quite a few more efficiently than this. The match is [...]


Related posts:<ol><li><a href='http://www.indented.co.uk/index.php/2009/10/02/get-dsacl/' rel='bookmark' title='Permanent Link: Get-DsAcl'>Get-DsAcl</a> <small>The goal of this PowerShell function is to create a...</small></li>
<li><a href='http://www.indented.co.uk/index.php/2010/01/22/limit-recursion-depth-with-get-childitem/' rel='bookmark' title='Permanent Link: Limit recursion depth with Get-ChildItem'>Limit recursion depth with Get-ChildItem</a> <small>A PowerShell function that allows directory recursion to a specified...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>A short script to list explicit rights assigned to a directory structure. It uses the recursive option of ls (an Alias for Get-ChildItem) to drop down through the directory structure.<br />
<span id="more-395"></span><br />
There are lots of little programs around that can do exactly the same thing, probably quite a few more efficiently than this.</p>
<p>The match is not case sensitive. If the value for $SecurityPrincipal is left blank the script will return all explicitly assigned rights.</p>
<pre lang="posh">
# Uses match, either a specific user / group or blank for all explicit rights
$SecurityPrincipal = "chris"
# The starting point
$BasePath = "C:\"

# An array to hold the data returned
$ExplicitRights = @()
ForEach ($DirEntry in (ls -r $BasePath)) {
  # Add an entry to the report where it matches the criteria set in the ? pipe

  $ExplicitRights += (Get-ACL -Path $DirEntry.FullName).Access `
    | Select-Object @{n="Path";e={($DirEntry.FullName)}}, `
      FileSystemRights,IsInherited,IdentityReference `
    | ?{ ((($_.IdentityReference.Value) -match $SecurityPrincipal) -and `
      ($_.IsInherited -eq $False))}
}
# Write the array to the screen. Piping into Export-CSV should work as well
$ExplicitRights
</pre>


<p>Related posts:<ol><li><a href='http://www.indented.co.uk/index.php/2009/10/02/get-dsacl/' rel='bookmark' title='Permanent Link: Get-DsAcl'>Get-DsAcl</a> <small>The goal of this PowerShell function is to create a...</small></li>
<li><a href='http://www.indented.co.uk/index.php/2010/01/22/limit-recursion-depth-with-get-childitem/' rel='bookmark' title='Permanent Link: Limit recursion depth with Get-ChildItem'>Limit recursion depth with Get-ChildItem</a> <small>A PowerShell function that allows directory recursion to a specified...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.indented.co.uk/index.php/2008/10/22/powershell-get-acl-listing-explicit-rights/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
