
<?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>Lead, Follow, or Move &#187; Permissions</title>
	<atom:link href="http://www.leadfollowmove.com/archives/tag/permissions/feed" rel="self" type="application/rss+xml" />
	<link>http://www.leadfollowmove.com</link>
	<description>Adam Bell on Deployment, Automation, PowerShell et al</description>
	<lastBuildDate>Thu, 22 Apr 2010 14:34:55 +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>Security Identifiers (SIDs) and NT Account name</title>
		<link>http://www.leadfollowmove.com/archives/powershell/security-identifiers-sids-and-nt-account-name</link>
		<comments>http://www.leadfollowmove.com/archives/powershell/security-identifiers-sids-and-nt-account-name#comments</comments>
		<pubDate>Mon, 26 Mar 2007 19:17:42 +0000</pubDate>
		<dc:creator>Adam Bell</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Permissions]]></category>
		<category><![CDATA[SDDL]]></category>
		<category><![CDATA[SID]]></category>

		<guid isPermaLink="false">http://www.leadfollowmove.com/archives/powershell/security-identifiers-sids-and-nt-account-name</guid>
		<description><![CDATA[I have a couple of functions that are quite useful when dealing with Active Directory permissions. Translate SID to NT Account: :get-NTaccount.ps1 #&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- function get-NTaccount #&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- { Param ( &#160;&#160;$SID &#160;&#160;) &#160;&#160;$id = New-Object System.Security.Principal.SecurityIdentifier($sid) &#160;&#160;$account = $id.Translate( [System.Security.Principal.NTAccount] ) &#160;&#160;return $account } &#160; #&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- get-NTaccount &#34;S-1-5-21-812403740-544655063-2921696178-1958&#34; In this function we take a SID in [...]]]></description>
			<content:encoded><![CDATA[<p>I have a couple of functions that are quite useful when dealing with Active Directory permissions. </p>
<p>Translate SID to NT Account:<br />
<a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode661');">:get-NTaccount.ps1</a></p>
<div id="quickcode661" class="quickcode"><code><br />
#&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-<br />
function get-NTaccount<br />
#&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-<br />
{<br />
Param (<br />
&nbsp;&nbsp;$SID<br />
&nbsp;&nbsp;)<br />
&nbsp;&nbsp;$id = New-Object System.Security.Principal.SecurityIdentifier($sid)<br />
&nbsp;&nbsp;$account = $id.Translate( [System.Security.Principal.NTAccount] )<br />
&nbsp;&nbsp;return $account<br />
}<br />
&nbsp;<br />
#&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-<br />
get-NTaccount &quot;S-1-5-21-812403740-544655063-2921696178-1958&quot;<br />
</code></div>
<p>In this function we take a SID in string format, and cast it as a <em>SecurityIdentifier</em> and then use the .Net method to translate this into the NT Account name.</p>
<p>Translate NT Account to SID:<br />
<a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode662');">:get-SID.ps1</a></p>
<div id="quickcode662" class="quickcode"><code><br />
#&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-<br />
function get-sid<br />
#&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-<br />
{<br />
Param (<br />
&nbsp;&nbsp;$DSIdentity<br />
&nbsp;&nbsp;)<br />
&nbsp;&nbsp;$ID = new-object System.Security.Principal.NTAccount($DSIdentity)<br />
&nbsp;&nbsp;return $ID.Translate( [System.Security.Principal.SecurityIdentifier] ).toString()<br />
}<br />
&nbsp;<br />
#&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-<br />
get-sid &quot;bella&quot;<br />
</code></div>
<p>This is basically the same premise as above, only we are working the other way around. If you provide a name without a domain prefix or UPN, the method presumes the current domain.</p>
<p>So with our Test OU, you can output the <a title="Security Descriptor String Format" href="http://msdn2.microsoft.com/en-us/library/aa379570.aspx">SDDL</a> format of the <em>Security Descriptor</em> to a text file to examine the permissions.<br />
<a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode663');">:noclick</a></p>
<div id="quickcode663" class="quickcode"><code><br />
$root = [adsi]&quot;&quot;<br />
$test = [adsi](&quot;LDAP://ou=test ou,&quot;+$root.distinguishedName)<br />
$test.psbase.get_objectsecurity().GetSecurityDescriptorSddlForm(&quot;All&quot;) &gt; DS-SDDL.txt<br />
</code></div>
<p>When you start playing around with <em>Security Discriptors</em>, and examining various permissions structures, it quickly becomes very useful to be able to translate SID&#8217;s back and forth to confirm things are working as expected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leadfollowmove.com/archives/powershell/security-identifiers-sids-and-nt-account-name/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting Filesystem permissions using SDDL format</title>
		<link>http://www.leadfollowmove.com/archives/powershell/setting-filesystem-permissions-using-sddl-format</link>
		<comments>http://www.leadfollowmove.com/archives/powershell/setting-filesystem-permissions-using-sddl-format#comments</comments>
		<pubDate>Tue, 23 Jan 2007 22:20:00 +0000</pubDate>
		<dc:creator>Adam Bell</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[NTFS]]></category>
		<category><![CDATA[Permissions]]></category>
		<category><![CDATA[SDDL]]></category>

		<guid isPermaLink="false">http://www.leadfollowmove.com/?p=4</guid>
		<description><![CDATA[When it comes to setting the permission on the filesystem there has already been some interesting conversation between Tony (MSHforFun blog) and Marc (MOW): http://mshforfun.blogspot.com/2005/12/play-with-acl-in-msh.html This is fine if you want to add your ACE into an existing DACL. But what if you want to completely overwrite the DACL and &#8220;roll-your-own&#8221;? I posed this question [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to setting the permission on the filesystem there has already been some interesting conversation between Tony (MSHforFun blog) and Marc (MOW):<br />
<span class="postbody" /><a target="_blank" href="http://mshforfun.blogspot.com/2005/12/play-with-acl-in-msh.html">http://mshforfun.blogspot.com/2005/12/play-with-acl-in-msh.html</a></p>
<p>This is fine if you want to add your ACE into an existing DACL. But what if you want to completely overwrite the DACL and &#8220;roll-your-own&#8221;? I posed this question on the MS Powershell newsgroup recently, and the reply was spot on (cheers Rob!). Basically you need to specify the DACL in SDDL format.</p>
<p>After about half a days googling for information on SDDL I found a few URL&#8217;s that provide some good information on the subject. I have posted the links on the Further Reading page (I&#8217;m having a few link issues here *sighs*. Spot the n00b!)<br />
OK, so let&#8217;s try it out:</p>
<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode41');">:replace-acl function</a></p>
<div id="quickcode41" class="quickcode"><code><br />
function replace-acl<br />
{<br />
Param (<br />
&nbsp;&nbsp;$sObject,<br />
&nbsp;&nbsp;$sSDDL<br />
&nbsp;&nbsp;)<br />
&nbsp;&nbsp;$acl = Get-Acl $sObject<br />
&nbsp;&nbsp;$acl.SetSecurityDescriptorSddlForm($sSDDL)<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;Set-Acl -aclObject $acl $sObject<br />
}<br />
replace-acl &quot;d:\&quot; &quot;O:BAG:BAD:AI(A;OICI;0x1301bf;;;AU)(A;OICI;FA;;;BA)(A;OICI;FA;;;SY)&quot;<br />
</code></div>
<p>Basically we&#8217;re passing the function the folder we want to apply the permissions to, and then our complete DACL in SDDL format.<br />
The first portion of the SDDL sets the Owner as Builtin-Administrators (O:BA), the POSIX compliant group to the same (G:BA) and the 3 ACE&#8217;s with the inherit flag on, and : Builtin-Administrators FullControl, System FullControl, and AuthenticatedUsers with a hex flag set, which equates to Modify.</p>
<p>The DACL will cascade down the directory tree to any child folders, which is great. However if any of these children have manual ACE&#8217;s added, or if inheritence has been turned of (by the inherit from parent flag being unticked) then the permissions will either merge in the case of the former, or not be applied at all in the case of the latter.</p>
<p>This can be rectified with a simple get-children function:</p>
<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode42');">:flush-acl function</a></p>
<div id="quickcode42" class="quickcode"><code><br />
function flush-acl<br />
{<br />
Param (<br />
&nbsp;&nbsp;$sObject<br />
&nbsp;&nbsp;)<br />
&nbsp;<br />
&nbsp;&nbsp;$col = Get-ChildItem $sObject -Recurse<br />
&nbsp;&nbsp;foreach ($item in $col)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;replace-acl $item.FullName &quot;O:BAG:BAD:&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;}<br />
}<br />
flush-acl &quot;d:\&quot;<br />
</code></div>
<p>I&#8217;ve found that by rewriting the DACL on each child folder, with just the Owner and Group information has the effect of dropping the existing manual ACE entries, and the bonus of turning the inheritence back on again. By applying the flush function and then replacing the DACL at the required level is a very effective way of repermissioning a directory tree, knowing that there&#8217;s no hidden surprises further down the tree!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leadfollowmove.com/archives/powershell/setting-filesystem-permissions-using-sddl-format/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
