<?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>PhishThis! &#187; Active Directory</title>
	<atom:link href="http://www.phishthis.com/category/active-directory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phishthis.com</link>
	<description></description>
	<lastBuildDate>Mon, 21 Jun 2010 17:34:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to give a user account rights to register its own Service Principal Name (SPN)</title>
		<link>http://www.phishthis.com/2009/12/30/how-to-give-a-user-account-rights-to-register-its-own-service-principal-name-spn/</link>
		<comments>http://www.phishthis.com/2009/12/30/how-to-give-a-user-account-rights-to-register-its-own-service-principal-name-spn/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 18:05:33 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Kerberos]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[ServicePrincipalName]]></category>
		<category><![CDATA[SPN]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/?p=146</guid>
		<description><![CDATA[<p>I recently had a SQL server where the SQL instance had a different name than the hostname. Not having rights to connect to SQL, I wasn&#8217;t aware of that. So, I registered the SPNs as they should have been registered, and it was still falling back to NTLM (see: failing). </p>
<p>SQL Server will register its own [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a SQL server where the SQL instance had a different name than the hostname. Not having rights to connect to SQL, I wasn&#8217;t aware of that. So, I registered the SPNs as they should have been registered, and it was still falling back to NTLM (see: failing). </p>
<p>SQL Server will register its own SPNs at startup &#8211; assuming the service account has rights to set its own SPN. To give the service account rights to self-register SPN (assuming you&#8217;re using a domain service account and not Network Service/Local System), you need to grant the service account rights to &#8220;Write Public Information&#8221; on itself in Active Directory.</p>
<p>1) Launch Active Directory Users and Computers<br />
2) Find your service account and hit the <b>Security</b> tab<br />
3) Select <strong>&#8220;SELF&#8221;</strong> in the <strong>&#8220;Groups or user names&#8221;</strong> listbox<br />
4) Find <strong>&#8220;Write public information&#8221;</strong> in the <strong>&#8220;Permissions for SELF&#8221;</strong> listbox and check <strong>&#8220;Allow&#8221;</strong><br />
5) Click OK</p>
<p><a href="http://www.phishthis.com/wp-content/uploads/2009/12/WritePublicInformation.png"><img src="http://www.phishthis.com/wp-content/uploads/2009/12/WritePublicInformation-231x299.png" alt="" title="WritePublicInformation" width="231" height="299" class="size-medium wp-image-147" /></a><br />
After, you&#8217;ll need to restart SQL Server for the SPN to register. Use <b>setspn -l domain\account</b> to verify that the account has properly registered. </p>
<p>If you do happen to be using Network Service or Local System, shame on you. That said you&#8217;ll just need to verify on the computer account in AD that SELF has &#8220;Validated write to service principal name&#8221; set to Allow. But, seriously, stop using Network Service or Local System (ESPECIALLY THAT!) and start using a domain account&#8230;or at the very least a local account. </p>
<p><DIV style="MARGIN-TOP: 10px; HEIGHT: 15px" class=zemanta-pixie><A class=zemanta-pixie-a title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/a789ff5a-54b4-4143-b96c-8931c8c8d0f5/"><IMG style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; FLOAT: right; BORDER-TOP: medium none; BORDER-RIGHT: medium none" class=zemanta-pixie-img alt="Reblog this post [with Zemanta]" src="http://img.zemanta.com/reblog_e.png?x-id=a789ff5a-54b4-4143-b96c-8931c8c8d0f5"></A><SPAN class="zem-script more-related pretty-attribution"><SCRIPT type="text/javascript" defer="defer" src="http://static.zemanta.com/readside/loader.js"></SCRIPT></SPAN></DIV></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2009/12/30/how-to-give-a-user-account-rights-to-register-its-own-service-principal-name-spn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to configure AD, SQL, and IIS for two-hop Kerberos authentication</title>
		<link>http://www.phishthis.com/2009/10/24/how-to-configure-ad-sql-and-iis-for-two-hop-kerberos-authentication-2/</link>
		<comments>http://www.phishthis.com/2009/10/24/how-to-configure-ad-sql-and-iis-for-two-hop-kerberos-authentication-2/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 00:01:48 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[IIS7]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Server Management]]></category>
		<category><![CDATA[Windows Server 2008]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Kerberos]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Web service]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/?p=138</guid>
		<description><![CDATA[<p>Recently, some of our developers were writing an app that required impersonation from the web service, as the user, to the database. Admittedly, Kerberos isn&#8217;t one of my strong points.</p>
<p>There were two hops here. From the user -&#62; IIS server and from IIS Server -&#62; SQL Server, but the application in IIS would impersonate the user [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, some of our developers were writing an app that required impersonation from the web service, as the user, to the database. Admittedly, <A class=zem_slink title="Kerberos (protocol)" href="http://en.wikipedia.org/wiki/Kerberos_%28protocol%29" rel=wikipedia>Kerberos</A> isn&#8217;t one of my strong points.</p>
<p>There were two hops here. From the user -&gt; IIS server and from IIS Server -&gt; SQL Server, but the application in IIS would impersonate the user when authenticating with the SQL server.</p>
<p>So, the idea here is that from the user to the IIS server, we know Kerberos will work. The user passes its ticket to the web service. Nothing unusual. From there, the web app, running as a custom app pool ID, needs to pretend (delegate) to be the user when it authenticates to the SQL server. </p>
<p>There are a few requirements.<br />
<strong>1) </strong>Your application in IIS should be running under a custom identity &#8211; domain\MyAppService<br />
<strong>2) </strong>SQL Server needs to be running under a domain service account &#8211; domain\MySQLService<br />
<strong>3)</strong> IIS needs to use Negotiate instead of NTLM for that application. It should do this by default, then fall back to NTLM. For whatever reason, my app was using NTLM. IIS should also have Windows Authentication enabled.<br />
<strong>4) </strong>Change your connection string to impersonate the site user</p>
<p><STRONG>Step 1</STRONG> &#8211; Set the SPN on your app pool ID for the site, for the hostname and FQDN.<br />
<CODE>setspn -a http/mysite domain\MyAppService<br />
setspn -a http/mysite.domain.com domain\MyAppService</CODE></p>
<p><STRONG>Step 2</STRONG> &#8211; Set the SPN for the SQL service on your SQL service account &#8211; assuming you use the default SQL port<br />
<CODE>setspn -a MSSQLSvc/hostname domain\MySQLService<br />
setspn -a MSSQLSvc/hostname.domain.com domain/MySQLService<br />
setspn -a MSSQLSvc/hostname:1433 domain\MySQLService<br />
setspn -a MSSQLSvc/hostname.domain.com:1433 domain/MySQLService</CODE><br />
Restart SQL</p>
<p><STRONG>Step 3</STRONG> &#8211; In Active Directory Users and Computers, find the service account, click the delegation tab, and trust it for delegation. You can set it for delegation to anywhere, or constrained delegation to the SPNs you&#8217;ll set for the SQL service account. </p>
<p><STRONG>Step 4</STRONG> &#8211; Force your site or application to use Negotiate. This won&#8217;t work with NTLM, so we&#8217;ll remove it. (Note: This is for IIS7/7.5)<br />
- Find and open your applicationHost.config. It&#8217;s probably under c:\windows\system32\inetsrv\config. You can also set this in the system.webServer section of the web.config for the application. </p>
<p>- Scroll to the bottom and above /configuration copy this in:<br />
[xml]<br />
   <location path="SitePath"><br />
        <system.webServer><br />
            <security><br />
                <authentication><br />
                    <windowsAuthentication></p>
<providers>
                            <add value="Negotiate" /><br />
                            <remove value="NTLM" />
                        </providers>
                    </windowsAuthentication><br />
                </authentication><br />
            </security><br />
        </system.webServer><br />
    </location><br />
[/xml]</p>
<p>If you get a 500 error after adding the above XML, it&#8217;s probably because Negotiate is already added elsewhere. Just remove the line that says add value=&#8221;Negotiate&#8221; and leave the remove NTLM line. </p>
<p>Reference: This post was extremely helpful in solving my problem &#8211; <A href="http://blogs.technet.com/askds/archive/2008/06/13/understanding-kerberos-double-hop.aspx">http://blogs.technet.com/askds/archive/2008/06/13/understanding-kerberos-double-hop.aspx</A> &#8211; in the end, I did pretty much everything in that post, and still had the IIS server passing anonymous to SQL, which is what tipped me off that it was using NTLM and not Negotiate.</p>
<p><DIV style="MARGIN-TOP: 10px; HEIGHT: 15px" class=zemanta-pixie><A class=zemanta-pixie-a title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/fbffe8a7-8bb0-4ce5-9df2-afc98ab58ee0/"><IMG style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; FLOAT: right; BORDER-TOP: medium none; BORDER-RIGHT: medium none" class=zemanta-pixie-img alt="Reblog this post [with Zemanta]" src="http://img.zemanta.com/reblog_e.png?x-id=fbffe8a7-8bb0-4ce5-9df2-afc98ab58ee0"></A><SPAN class="zem-script more-related pretty-attribution"><SCRIPT type="text/javascript" defer="defer" src="http://static.zemanta.com/readside/loader.js"></SCRIPT></SPAN></DIV></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2009/10/24/how-to-configure-ad-sql-and-iis-for-two-hop-kerberos-authentication-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Powershell 2.0 CTP &#8211; Remoting &#8211; PowerShell Remove WDS</title>
		<link>http://www.phishthis.com/2007/11/20/powershell-20-ctp-remoting-powershell-remove-wds/</link>
		<comments>http://www.phishthis.com/2007/11/20/powershell-20-ctp-remoting-powershell-remove-wds/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 22:47:07 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell 2.0 CTP]]></category>
		<category><![CDATA[Server Management]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PowerShell Script]]></category>
		<category><![CDATA[Remove WDS Script]]></category>
		<category><![CDATA[scripting to uninstall wds]]></category>
		<category><![CDATA[WDS Removal]]></category>
		<category><![CDATA[WSUS WDS]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/2007/11/20/powershell-20-ctp-remoting-powershell-remove-wds/</guid>
		<description><![CDATA[<p>So, with PowerShell 2.0 CTP&#8217;s arrival, and me finally having some time to mess around with some of the new features, here&#8217;s my previous (and first popular) post re-hashed for PowerShell 2.0 CTP. This will only work on machines with WS-Management installed, so it probably won&#8217;t work on most of your machines (unless you&#8217;ve deployed it), but [...]]]></description>
			<content:encoded><![CDATA[<p>So, with PowerShell 2.0 CTP&#8217;s arrival, and me finally having some time to mess around with some of the new features, here&#8217;s my previous (and first popular) post re-hashed for PowerShell 2.0 CTP. This will only work on machines with WS-Management installed, so it probably won&#8217;t work on most of your machines (unless you&#8217;ve deployed it), but it works well in my little test world. It utilizes two new features. These features are the [ADSISearcher] and Invoke-Expression. Instead of creating all of the Directory Service objects each time, you can just cast the ASDISearcher type and you&#8217;re done. Invoke-Expression allows you to use the -computer parameter and pass one, or many, computers to the cmdlet. I chose to use a single command here.</p>
<p><code><br />
[adsisearcher]$searcher = "LDAP://dc=foo,dc=bar,dc=com"<br />
$searcher.filter = "(objectclass=computer)"<br />
foreach ($machine in ($searcher.findall()))<br />
{<br />
   invoke-expression -computer $machine.properties.cn -command "c:\windows\`$NtUninstallKB917013`$\spuninst\spuninst.exe /q /norestart"<br />
}</code></p>
<p>I haven&#8217;t had a chance to test it, but you could use mutiple computers. We could change the foreach loop to write to a text file, then read that file for the computer names.</p>
<p><code>...<br />
foreach ($machine in ($searcher.findall())){ add-content c:\temp\machines.txt "$($machine.properties.cn)" }<br />
invoke-expression -computer (get-content c:\temp\machines.txt) -command "c:\windows\`$NtUninstallKB917013`$\spuninst\spuninst.exe /q /norestart"<br />
</code></p>
<p>That&#8217;ll kick off on 50 machines at a time. You can adjust that via the -ThrottleLimit parameter, and make it more or less, depending on bandwidth, CPU power, etc.</p>
<p>As you can see, I tend to learn better by example or by practical application. You&#8217;ll never see me write a book :) More soon!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2007/11/20/powershell-20-ctp-remoting-powershell-remove-wds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WSUS/WDS Debacle</title>
		<link>http://www.phishthis.com/2007/10/30/wsuswds-debacle/</link>
		<comments>http://www.phishthis.com/2007/10/30/wsuswds-debacle/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 02:47:11 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Server Management]]></category>
		<category><![CDATA[powershell psexec foreach]]></category>
		<category><![CDATA[PowerShell Script]]></category>
		<category><![CDATA[WDS]]></category>
		<category><![CDATA[Windows Desktop Search]]></category>
		<category><![CDATA[Windows Desktop Search Removal]]></category>
		<category><![CDATA[Windows Desktop Search Removal Script]]></category>
		<category><![CDATA[WSUS]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/2007/10/30/wsuswds-debacle/</guid>
		<description><![CDATA[<p>I don&#8217;t understand the big issue with the accidental release of WDS (Windows Desktop Search) via WSUS (here). It wasn&#8217;t like MS said &#8220;Muhuhahaha, let&#8217;s release WDS  to the masses via WSUS!&#8221; I mean&#8230;why? There&#8217;s no compelling reason for this besides a simple mistake. Now, the fact that the mistake was made is a little scary. I don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t understand the big issue with the accidental release of WDS (Windows Desktop Search) via WSUS (<a href="http://blogs.technet.com/wsus/archive/2007/10/25/wds-update-revision-follow-up.aspx">here</a>). It wasn&#8217;t like MS said &#8220;Muhuhahaha, let&#8217;s release WDS  to the masses via WSUS!&#8221; I mean&#8230;why? There&#8217;s no compelling reason for this besides a simple mistake. Now, the fact that the mistake was made is a little scary. I don&#8217;t want some blue-screen causing driver or security update released to 500 servers. That might wreck my month&#8230;no, year. Then again, how many critical servers are set to auto-update? Test and QA boxes, but never production, unless you&#8217;re load balanced (ie, IIS boxes), and can stagger update times. At least that&#8217;s how I see it&#8230;</p>
<p>Removal was pretty easy, too. Altiris works wonders. But, let&#8217;s say you don&#8217;t have Altiris. You could use (ready for this?) PowerShell. They provide the removal instructions on the WDS blog entry. Using another handy utility, <a href="http://www.microsoft.com/technet/sysinternals/Security/PsExec.mspx">PSEXEC</a>, you could very easily run a script to remove WDS. It might take a while, depending on the number of machines, but it&#8217;ll work&#8230;and without much effort.</p>
<p>For the sake of argument (and typing), let&#8217;s say it went to every box on your domain, server and desktop. This will only return 1,000 objects, so you&#8217;ll need to break it out by OU or some other method if you have more than that. Here&#8217;s my remove wds script (excuse the formatting&#8230;)</p>
<p><code><br />
$root = new-object DirectoryServices.DirectoryEntry<br />
$searcher = new-object DirectoryServices.DirectorySearcher<br />
$searcher.SearchRoot = $root<br />
$searcher.Filter = "(samaccounttype=805306369)"<br />
$machines = $searcher.FindAll()<br />
foreach ($machine in $machines)<br />
{<br />
  psexec.exe "\\$($machine.properties.cn)" -d - c:\windows\`$NtUninstallKB917013`$\spuninst\spuninst.exe /q /norestart<br />
  #run PSEXEC, execute sp uninstaller quietly, with no restart. PSEXEC will not wait for app to finish<br />
  #and will only wait 5 seconds before timing out when attempting to run the remote command<br />
}<br />
</code></p>
<p>Now, you&#8217;ve kicked off the task to remove the update from all of your machines&#8230;or 1,000 of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2007/10/30/wsuswds-debacle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Get-ServerNames.ps1</title>
		<link>http://www.phishthis.com/2007/09/28/get-servernamesps1/</link>
		<comments>http://www.phishthis.com/2007/09/28/get-servernamesps1/#comments</comments>
		<pubDate>Sat, 29 Sep 2007 00:14:42 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Server Management]]></category>

		<guid isPermaLink="false">http://www.phishthis.com/2007/09/28/get-servernamesps1/</guid>
		<description><![CDATA[<p>Here&#8217;s the script I metioned a few days ago. I wrote this a while back (Pre-RC0, I think).</p>
<p> Anyway, if you&#8217;ve got a bunch of servers that you need to perform a common task on (copy files, check event logs, etc), this is handy&#8230;however, it only works if you&#8217;ve got the Managed By field set in AD. [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the script I metioned a few days ago. I wrote this a while back (Pre-RC0, I think).</p>
<p> Anyway, if you&#8217;ve got a bunch of servers that you need to perform a common task on (copy files, check event logs, etc), this is handy&#8230;however, it only works if you&#8217;ve got the Managed By field set in AD. Otherwise, you&#8217;re SOL. First, it makes sure the account name given exists in AD, then searches AD for and computer objects managed by that account. It uses write-output to return the list of servers. It outputs strings, not objects, since that&#8217;s all I needed out of it.</p>
<p>Syntax is: .\get-servernames.ps1 &lt;samaccountname&gt;<br />
[powershell]<br />
$root = new-object DirectoryServices.DirectoryEntry &#8216;LDAP://dc=foo,dc=bar,dc=com&#8217;<br />
$searcher = new-object DirectoryServices.DirectorySearcher<br />
$searcher.SearchRoot = $root<br />
$searcher.Filter = &#8220;(samaccountname=$($args[0]))&#8221;<br />
$results = $searcher.findOne()<br />
if ($results -eq $null) {<br />
 write-host -fore &#8216;blue&#8217; -back &#8216;white&#8217; &#8220;`&#8221;$($args[0])`&#8221; not found&#8221;<br />
 exit(1)<br />
}<br />
else {<br />
 $dn = $results.GetDirectoryEntry().distinguishedname<br />
 $searcher.Filter = &#8220;(&amp;(samaccounttype=805306369)(managedby=$($dn)))&#8221;<br />
 $servers = $searcher.FindAll()<br />
  if ($($servers.count) -gt 0) {<br />
   foreach ($server in $servers) { write-output &#8220;$($server.GetDirectoryEntry().cn)&#8221; }<br />
 }<br />
}<br />
[/powershell]<br />
<font face="Georgia">As I mentioned, this is pretty handy for copying files to groups of servers, checking error logs via <a href="http://www.microsoft.com/technet/sysinternals/Security/PsLogList.mspx">psloglist</a>, doing inventory, and more. </font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phishthis.com/2007/09/28/get-servernamesps1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
