 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Managing Orphaned SIDs on AD objects</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/managing-orphaned-sids-on-ad-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/managing-orphaned-sids-on-ad-objects/</link>
	<description></description>
	<lastBuildDate>Wed, 22 May 2013 18:27:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: scriptlover</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/managing-orphaned-sids-on-ad-objects/#comment-81301</link>
		<dc:creator>scriptlover</dc:creator>
		<pubDate>Wed, 08 Sep 2010 17:39:19 +0000</pubDate>
		<guid isPermaLink="false">#comment-81301</guid>
		<description><![CDATA[The fellow above is correct. Don&#039;t let the problem happen AT ALL. Unfortunately sometimes you inherit an environment where this has already happened.

Firstly be CAREFULL!! Make sure you test the following scripts against your environment carefully before you try and run it whole hog!!

Powershell is the answer. 
First Find the Orphaned SIDS:

$SearchFolder = &quot;W:&quot;


Get-ChildItem $searchfolder -Recurse &#124; foreach {
	if ($_.PSIsContainer -eq $True)
    	{
		$folderacl = $_.getaccesscontrol()
		$folder=$_
		$Orphans = @()
		$folderacl.Access &#124; foreach {
			if (-not $_.isinherited)
				{
				if ($_.IdentityReference -match &quot;S-1-5-21-&quot;)
					{
					$Orphans += $_
					}
				}
			}
		foreach ($Orphan in $Orphans)
			{
			$folder.fullname + &quot;  &quot; + $Orphan.IdentityReference &gt;&gt; OUtput.txt
			}
		}
	}

The code to remove the orphaned SIDS goes under &quot;foreach ($Orphan in $Orphans).&quot; I created a second script identical to the first one and simply replaced the section as follows:

foreach ($Orphan in $Orphans)
			{
			$folder.fullname + &quot;  &quot; + $Orphan.IdentityReference
			$ACLtoRemove = $Orphan
			$folder.fullname + &quot;  &quot; + $ACLtoRemove.IdentityReference
					
			$colRights = $ACLtoRemove.FileSystemRights
			$InheritanceFlag = $ACLtoRemove.InheritanceFlags
			$PropagationFlag = $ACLtoRemove.PropagationFlags 
			
			$objType = $ACLtoRemove.AccessControlType
			
			$objUser =$ACLtoRemove.IdentityReference
			
			$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule `
			    ($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType) 
					
					
			$objACL = Get-Acl $folder.fullname
			$objACL.RemoveAccessRule($objACE) 
					
			Set-Acl $folder.fullname $objACL
			}]]></description>
		<content:encoded><![CDATA[<p>The fellow above is correct. Don&#8217;t let the problem happen AT ALL. Unfortunately sometimes you inherit an environment where this has already happened.</p>
<p>Firstly be CAREFULL!! Make sure you test the following scripts against your environment carefully before you try and run it whole hog!!</p>
<p>Powershell is the answer.<br />
First Find the Orphaned SIDS:</p>
<p>$SearchFolder = &#8220;W:&#8221;</p>
<p>Get-ChildItem $searchfolder -Recurse | foreach {<br />
	if ($_.PSIsContainer -eq $True)<br />
    	{<br />
		$folderacl = $_.getaccesscontrol()<br />
		$folder=$_<br />
		$Orphans = @()<br />
		$folderacl.Access | foreach {<br />
			if (-not $_.isinherited)<br />
				{<br />
				if ($_.IdentityReference -match &#8220;S-1-5-21-&#8221;)<br />
					{<br />
					$Orphans += $_<br />
					}<br />
				}<br />
			}<br />
		foreach ($Orphan in $Orphans)<br />
			{<br />
			$folder.fullname + &#8221;  &#8221; + $Orphan.IdentityReference &gt;&gt; OUtput.txt<br />
			}<br />
		}<br />
	}</p>
<p>The code to remove the orphaned SIDS goes under &#8220;foreach ($Orphan in $Orphans).&#8221; I created a second script identical to the first one and simply replaced the section as follows:</p>
<p>foreach ($Orphan in $Orphans)<br />
			{<br />
			$folder.fullname + &#8221;  &#8221; + $Orphan.IdentityReference<br />
			$ACLtoRemove = $Orphan<br />
			$folder.fullname + &#8221;  &#8221; + $ACLtoRemove.IdentityReference</p>
<p>			$colRights = $ACLtoRemove.FileSystemRights<br />
			$InheritanceFlag = $ACLtoRemove.InheritanceFlags<br />
			$PropagationFlag = $ACLtoRemove.PropagationFlags </p>
<p>			$objType = $ACLtoRemove.AccessControlType</p>
<p>			$objUser =$ACLtoRemove.IdentityReference</p>
<p>			$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule `<br />
			    ($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType) </p>
<p>			$objACL = Get-Acl $folder.fullname<br />
			$objACL.RemoveAccessRule($objACE) </p>
<p>			Set-Acl $folder.fullname $objACL<br />
			}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: epsign2001</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/managing-orphaned-sids-on-ad-objects/#comment-72651</link>
		<dc:creator>epsign2001</dc:creator>
		<pubDate>Thu, 14 Jan 2010 16:34:18 +0000</pubDate>
		<guid isPermaLink="false">#comment-72651</guid>
		<description><![CDATA[There is a tool that will centrally help you locate orphaned SIDs across the servers. Security Explorer.]]></description>
		<content:encoded><![CDATA[<p>There is a tool that will centrally help you locate orphaned SIDs across the servers. Security Explorer.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/9 queries in 0.013 seconds using memcached
Object Caching 282/285 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-23 01:29:32 -->