<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Vasya&#039;s Weblog</title>
	<atom:link href="http://vasya10.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://vasya10.wordpress.com</link>
	<description>Vasya&#039;s Tech Blog</description>
	<lastBuildDate>Fri, 20 Jan 2012 01:47:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='vasya10.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Vasya&#039;s Weblog</title>
		<link>http://vasya10.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://vasya10.wordpress.com/osd.xml" title="Vasya&#039;s Weblog" />
	<atom:link rel='hub' href='http://vasya10.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Start SharePoint virtual machines via command line</title>
		<link>http://vasya10.wordpress.com/2012/01/20/start-sharepoint-virtual-machines-via-command-line/</link>
		<comments>http://vasya10.wordpress.com/2012/01/20/start-sharepoint-virtual-machines-via-command-line/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 01:47:38 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[Sharepoint 2010]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=275</guid>
		<description><![CDATA[Like it or not, there is no better choice except developing SharePoint 2010 using a virtual machine. While VMWare is pretty good, it is also a bloated software. My machine runs two vm-s, trying to simulate a real-world SharePoint environment &#8211; one being the DNS and hosting the AD and SQL Server 2008 R2 and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=275&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Like it or not, there is no better choice except developing SharePoint 2010 using a virtual machine. While VMWare is pretty good, it is also a bloated software. My machine runs two vm-s, trying to simulate a real-world SharePoint environment &#8211; one being the DNS and hosting the AD and SQL Server 2008 R2 and another the Windows Server 2008 R2, Visual Studio 2010 and SharePoint 2010 itself. Since I have to stop and start VMWares frequently, I found the following command line script very useful.</p>
<p><pre class="brush: powershell;">

net start &quot;VMWare Agent Service&quot;
net start &quot;VMWare Authorization Service&quot;
net start &quot;VMWare DHCP Service&quot;
net start &quot;VMWare NAT Service&quot;
&quot;C:\Program Files (x86)\VMware\VMware Workstation\vmrun&quot; start &quot;C:\VirtualMachines\sqlserver.vmx&quot;
&quot;C:\Program Files (x86)\VMware\VMware Workstation\vmrun&quot; start &quot;C:\VirtualMachines\sharepoint.vmx&quot;

</pre></p>
<p>Save the above file as a batch file and store in a directory accessible by PATH.</p>
<p>For stopping, reverse the commands, use &#8220;suspend&#8221; instead of &#8220;start&#8221;.</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/275/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=275&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2012/01/20/start-sharepoint-virtual-machines-via-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>
	</item>
		<item>
		<title>Groovy OLC #2 &#8211; Strand Puzzle 1914</title>
		<link>http://vasya10.wordpress.com/2012/01/11/groovy-olc-2-strand-puzzle-1914/</link>
		<comments>http://vasya10.wordpress.com/2012/01/11/groovy-olc-2-strand-puzzle-1914/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 01:08:17 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[OLC]]></category>
		<category><![CDATA[continous fractions]]></category>
		<category><![CDATA[olc]]></category>
		<category><![CDATA[ramanujan]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=261</guid>
		<description><![CDATA[I think it was the year 1986 when I participated in an interschool programming competition in Chennai. I wasn&#8217;t very good at math, but I did tag along with a couple of my friends who were darn good at it. There were three problems given that we have to solve using GW-BASIC in about 30 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=261&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I think it was the year 1986 when I participated in an interschool programming competition in Chennai. I wasn&#8217;t very good at math, but I did tag along with a couple of my friends who were darn good at it. There were three problems given that we have to solve using GW-BASIC in about 30 minutes. There were probably 100 participants. I did get a peep into a few poor guys inside the computer room who were typing our solutions into the computer blindly and see if they worked. I just remember only one of the problems. I didn&#8217;t get the correct solution, but one of my friends &#8211; <a href="http://blogs.msdn.com/b/sowmy/">Sowmy Srinivasan</a>, did and win the competition.</p>
<p>Years later, I learned that this was a very interesting puzzle tackled by the genius Srinivasa Ramanujan. In the year 1914, PC Mahalanobis, a Kings college student in England, got hold of a puzzle from the Strand magazine.</p>
<p>&#8220;In a given street of houses with consecutive numbers between 50 and 500, find the house number, for which, the sum of numbers on the left is equal to the sum of numbers on the right&#8221;</p>
<p>In other words, given &#8216;n&#8217; number of houses, find the house number &#8216;m&#8217; that would sum(1..m-1) = sum(m+1..n).</p>
<p>Mahalanobis solved the problem by trial and error and went to Ramanujan to show it. Ramanujan was cooking some vegetables in the pan. The instant he heard the problem, Ramanujan, while still frying his veggies, not only gave the answer to the puzzle, but also provided the generic formula that would give infinite number of solutions. The problem belongs to the area called Continuous Fractions and is very fascinating. The problem can be reduced to x*x &#8211; Dy*y = ±1 and has been tackled by ~10th century Indian mathematician Brahmaguputa using a method called chakravala. I will probably write up on the &#8220;chakravala&#8221; method later. The Ramanujan anecdote is documented in several places on the net and a simple search will provide more interesting details.</p>
<p>So I was working on something in Groovy, I suddenly got reminded of this problem and was thinking if this can be solved as a Groovy OLC. I am going to use the brute-force method rather than solving via the quadratic equation, because it nicely demostrates the List capabilities of Groovy. It does run slow for large numbers, but speed or optimization is not the point here.</p>
<p>So here is Groovy OLC #2 &#8211; Ramanujan&#8217;s Continuous Fractions (via brute force method)</p>
<p><pre class="brush: groovy;">
public test_ramanujan_continous_fraction() {
(1..100).each { n, houses = 1..n -&gt; houses.eachWithIndex {m, i -&gt; if (houses.subList(0,i).sum() == houses.subList(i+1,houses.size()).sum()) println &quot;house# = $m, total_houses = $n&quot; } }
}

Result:
house# = 1, total_houses = 1
house# = 6, total_houses = 8
house# = 35, total_houses = 49
</pre></p>
<p>Ignore the first one, as I am not bothered about boundary conditions, though its technically correct.</p>
<p>[6,8] = sum(1..5) = sum(7..8) = 15<br />
[35,49] = sum(1..34) = sum(36..49) = 595</p>
<p>Lets retest it with the actual problem from the Strand magazine:</p>
<p><pre class="brush: groovy;">
public test_ramanujan_continous_fraction() {
(50..500).each { n, houses = 1..n -&gt; houses.eachWithIndex {m, i -&gt; if (houses.subList(0,i).sum() == houses.subList(i+1,houses.size()).sum()) println &quot;house# = $m, total_houses = $n&quot; } }
}

Result:
house# = 204, total_houses = 288
</pre></p>
<p>This is the actual solution that Ramunjan gave instantly to the Strand&#8217;s puzzle.</p>
<p>From Groovy&#8217;s point of view, the most interesting thing is the second argument in the first closure &#8211; &#8220;houses&#8221; &#8211; is actually a <strong>variable defintion</strong> which is a <strong>function of the first argument</strong>, ie houses = f(n) !!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/261/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/261/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/261/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=261&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2012/01/11/groovy-olc-2-strand-puzzle-1914/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>
	</item>
		<item>
		<title>Groovy OLC #1 &#8211; Prime Numbers</title>
		<link>http://vasya10.wordpress.com/2012/01/10/groovy-olc-1/</link>
		<comments>http://vasya10.wordpress.com/2012/01/10/groovy-olc-1/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 23:36:55 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[OLC]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[olc]]></category>
		<category><![CDATA[prime numbers]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=252</guid>
		<description><![CDATA[It is interesting how formatting conventions keep changing with the programming languages. I&#8217;m not talking about naming conventions, but just text formatting conventions aka code-layout conventions. In Java, you dont commonly see beginning separate braces in a new line, although its okay for the ending braces. While in .NET, its a norm to have curly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=252&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It is interesting how formatting conventions keep changing with the programming languages. I&#8217;m not talking about naming conventions, but just text formatting conventions aka code-layout conventions.</p>
<p>In Java, you dont commonly see beginning separate braces in a new line, although its okay for the ending braces. While in .NET, its a norm to have curly braces in separate lines. Inline code is also very rare in Java and .NET, except for get and set, but in Groovy/JavaScript, it seems to be a very common occurrence. Some of these conventions evolve as a tradition and some right from the invention. In Pascal, structured code was considered art. In Python block indentations are obligatory. Code format conventions, just like naming conventions are very subjective and sometimes personal and if a team cannot agree on one, its a rough road. Although some modern IDE-s have smartened up and present the personalized formatted code to the developer, while the source control would store a standard version. Some of the preferences are driven by language features too.</p>
<p>Closures, especially compact ones, are very intriguing when presented in a single line and some times very challenging. Solutions to puzzles and problems when rewritten in a single line look very catchy. Those who have coded in Prolog would perhaps realize what it means to say that a piece of code is work of art. You can do a regular findBy logic in Prolog, but doing it &#8220;Prolog&#8221;-way via predicates is certainly challenging.</p>
<p>So here is a One-Liner-Closure (OLC) that calculates the prime numbers &gt; 2.</p>
<p>Given: a list of natural numbers<br />
Find: all the prime numbers</p>
<p><pre class="brush: groovy;">
void find_prime_numbers() {
def list = 1..100
println list.findAll { x -&gt; (2..Math.sqrt(x)).every { x % it != 0 } }
}

Result:
[3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/252/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/252/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/252/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=252&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2012/01/10/groovy-olc-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>
	</item>
		<item>
		<title>Inconspicuous SharePoint Quirks #5 &#8211; The Case of the Client Context</title>
		<link>http://vasya10.wordpress.com/2011/12/28/inconspicuous-sharepoint-quirks-5-the-case-of-the-client-context/</link>
		<comments>http://vasya10.wordpress.com/2011/12/28/inconspicuous-sharepoint-quirks-5-the-case-of-the-client-context/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 20:03:50 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Sharepoint 2010]]></category>
		<category><![CDATA[cannot contact site at specified url]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=241</guid>
		<description><![CDATA[Cannot contact site at specified URL The biggest advantage of SharePoint is probably the lack of useful official documentation. Thanks to it, numerous blogs and forums propose solutions and answers to more numerous problems. Some of them work, several don&#8217;t, as problem domain is always vastly huge when compared to the answer domain. For example, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=241&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Cannot contact site at specified URL</strong></p>
<p>The biggest advantage of SharePoint is probably the lack of useful official documentation. Thanks to it, numerous blogs and forums propose solutions and answers to more numerous problems. Some of them work, several don&#8217;t, as problem domain is always vastly huge when compared to the answer domain. For example, a simple combination of misbehaving USB driver + a command window open in non-Admin mode + an IIS session stored in-proc + neighbor&#8217;s dog&#8217;s wheezing bark + Saturn in conjunction with Mars in Aries constellation &#8211; all these could combinedly error an API out in SharePoint. And obviously no forum, let alone technical support, would be able to provide an answer to that. The programmer has to use the final weapon &#8211; perseverance.</p>
<p>So I was trying to use the ClientContext to get some data out of my sharepoint site, which is in a VM. Created a simple console project and the following code to get data from a site:</p>
<p><pre class="brush: csharp;">
public Web GetRootWeb() {
Web rootWeb;
Uri uri = new Uri(&quot;http://sp:2010&quot;);
using (ClientContext clientContext = new ClientContext(uri) {
clientContext.Credentials = CredentialCache.DefaultNetworkCredentials;
clientContext.Load(clientContext.Web);
clientContext.ExecuteQuery();
rootWeb = clientContext.Web;
}
return rootWeb;
}
</pre></p>
<p>No matter what variations I tried &#8211; credentials, permissions, I always got the following error: &#8220;Cannot contact site at specified URL http://sp:2010&#8243;. Luckily I had another web application in the same server. And that worked. So something must be wrong with this sharepoint site. This site was a migration from 2007, so first I thought it could be a possibility.</p>
<p><strong>Step 1: Inspect the closed-source code</strong><br />
The ClientRequestException was being thrown from the ClientContext.EnsureFormDigest() method. Having worked with open source for several years gives that irritable itch of peeping into others code. So I fired up .Net Reflector and inspected the method:</p>
<p><a href="http://vasya10.files.wordpress.com/2011/12/ensureformdigest.png"><img class="alignnone size-medium wp-image-246" title="EnsureFormDigest" src="http://vasya10.files.wordpress.com/2011/12/ensureformdigest.png?w=300&#038;h=217" alt="" width="300" height="217" /></a></p>
<p>The first thing the method does is get an asmx file &#8211; its actually the _vti_bin/sites.asmx as the following method shows:</p>
<p><a href="http://vasya10.files.wordpress.com/2011/12/getsitesasmx.png"><img class="alignnone size-full wp-image-247" title="GetSitesAsmx" src="http://vasya10.files.wordpress.com/2011/12/getsitesasmx.png?w=630" alt=""   /></a></p>
<p>So does this service work against a soap query? Also notice the 2nd and 3rd highlights. Both conditions (actually 3) throw the same exception and error message. So which one failed here? Was a non 200 http code returned? Was the responseContentType not text/xml? Or was m_formDigestInfo null? Pretty much written by a programmer who does not know the fundamentals of debugging. And thats probably why Microsoft&#8217;s code is closed, so strangers like me cant code review it. As a best practice, error conditions and error messages should have a monogamous relationship or else a dna test is required to find out who is whose child.</p>
<p><strong>Step 2: Rinse with a different agent &#8211; Use &#8220;Soap&#8221; UI</strong><br />
I fire up soap-UI 4.0 and add the wsdl. Since the site is behind NTLM Windows authentication, a challenge request pops up, I enter the credentials for the site (in this case the farmadmin account) and nope &#8211; it does not work. I get a 302 Found error and thats followed by a 401 Unauthorized in the same trace. Well 401 is not what I got before. I try the same with the second web app but that works fine again.</p>
<p><strong>Step 3: Burp it out</strong><br />
After turning on both the http log and error log in the soapUI, I conclude that the credentials may not be passed correctly. After reading <a href="http://stackoverflow.com/questions/914899/testing-webservice-with-soapui-windows-authentication">this thread</a>, I fire up Burp Suite, goto Options tab, check the &#8220;do www authenticate&#8221; option, add the servers and the user name/password/domain combination, turn the interceptor off. Well, the 401 is not there anymore, because the BurpSuite makes sure that the header contains the username/password. But the 302 Found still happens.</p>
<p><strong>Step 4: Always exchange dirty notes for good notes in the bank</strong><br />
Obviously IIS is doing some thing here. I replaced the sp:2010&#8242;s web.config with the second webapp&#8217;s web.config in-toto, recycle app pool and try to hit with soapUI. Voila, Im getting a successful connection now. So some line in the web.config is the culprit. Next I reverted the web.config and started aping section-by-section from the working web.config and I finally come to this line:</p>
<p><pre class="brush: xml;">
&lt;!-- &lt;sessionState mode=&quot;SQLServer&quot; timeout=&quot;60&quot; allowCustomSqlDatabase=&quot;true&quot; sqlConnectionString=&quot;Data Source=db;Initial Catalog=SessionStateService_f84b37c3424f46afa09cdacd278a95fa;Integrated Security=True;Enlist=False;Connect Timeout=15&quot; /&gt; --?
&lt;sessionState mode=&quot;InProc&quot; cookieless=&quot;AutoDetect&quot; timeout=&quot;20&quot; /&gt;
</pre></p>
<p>This section is from the trouble-some site&#8217;s web.config. I uncomment the first line, comment the InProc mode line, recycle app pool and whoa! I get a successful connection. So the sessionState set to InProc mode is somehow influencing the soap query which is what the EnsureFormDigest uses and throws an ambiguous ClientRequestException.</p>
<p>I don&#8217;t know why a seemingly unrelated sessionState causes an issue with soap query when trying to connect via console application. Thats probably a reflection for another Christmas day. Atleast it works now from Console. I had to make a slight modification while trying to do the same from a web application. From console, the DefaultNetworkCredentials works fine, but from a web app, you have to use the actual site credentials to connect to the site.</p>
<p><em>The Title is a tribute to Perry Mason novels.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/241/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=241&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2011/12/28/inconspicuous-sharepoint-quirks-5-the-case-of-the-client-context/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>

		<media:content url="http://vasya10.files.wordpress.com/2011/12/ensureformdigest.png?w=300" medium="image">
			<media:title type="html">EnsureFormDigest</media:title>
		</media:content>

		<media:content url="http://vasya10.files.wordpress.com/2011/12/getsitesasmx.png" medium="image">
			<media:title type="html">GetSitesAsmx</media:title>
		</media:content>
	</item>
		<item>
		<title>WebLogic Tips #3 &#8211; Missing Weblogic WrapperImpl</title>
		<link>http://vasya10.wordpress.com/2011/12/16/weblogic-tips-3-missing-weblogic-wrapperimpl/</link>
		<comments>http://vasya10.wordpress.com/2011/12/16/weblogic-tips-3-missing-weblogic-wrapperimpl/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 00:06:27 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Weblogic]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=231</guid>
		<description><![CDATA[I was running a JUnit Test on a code that accessed data from a database via a stored proceudre. The output of the stored proc is an Oracle Type object. It threw the following error: java.lang.NoClassDefFoundError: weblogic/utils/wrapper/WrapperImpl &#8230;. (application related methods)&#8230; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) But the same use case worked fine within the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=231&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was running a JUnit Test on a code that accessed data from a database via a stored proceudre. The output of the stored proc is an Oracle Type object. It threw the following error:</p>
<p>java.lang.NoClassDefFoundError: weblogic/utils/wrapper/WrapperImpl<br />
&#8230;. (application related methods)&#8230;</p>
<p>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</p>
<p>But the same use case worked fine within the web environment. Turns out that the missing jar was com.bea.core.utils.wrapper-1.3.0.0.jar. Add this to your test classes or if you are using Maven &#8211; add it to pom.xml in test scope:</p>
<p><pre class="brush: xml;">

&lt;dependency&gt;
&lt;groupId&gt;oracle.weblogic.modules&lt;/groupId&gt;
&lt;artifactId&gt;com.bea.core.utils.wrapper&lt;/artifactId&gt;
&lt;version&gt;1.3.0.0&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/231/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=231&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2011/12/16/weblogic-tips-3-missing-weblogic-wrapperimpl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>
	</item>
		<item>
		<title>Groovy #4</title>
		<link>http://vasya10.wordpress.com/2011/12/10/groovy-4/</link>
		<comments>http://vasya10.wordpress.com/2011/12/10/groovy-4/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 02:33:54 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=224</guid>
		<description><![CDATA[Find key by value in a map with a list of values One of the greatest assets of Groovy syntax is how easy it makes to manipulate lists and maps. In fact, the second most clumsy part of Java syntax and implementation are the Collections. The Calendar takes the honors. Collections are functional, but very [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=224&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Find key by value in a map with a list of values</h3>
<p>One of the greatest assets of Groovy syntax is how easy it makes to manipulate lists and maps. In fact, the second most clumsy part of Java syntax and implementation are the Collections. The Calendar takes the honors. Collections are functional, but very cumbersome and laborious to implement, ie when compared to Groovy. Even if one is hesitant to learn functional programming or succumbing to the Obsessive Closure Designer syndrome, it is illustrative to know how easy it is to manipulate collections in Groovy.</p>
<p><pre class="brush: groovy;">

def mapOfListValues = [a:[1,2], b:[3,4], c:[5,6], d:[7,8]]

</pre></p>
<p>So find the key to which a given number belongs to and return a default value if not found.</p>
<p><pre class="brush: groovy;">

def findKey = { value -&gt; (mapOfListValues.find { value in it.value }?.key)?:'Not Found' }
assert findKey(3) == 'b'
assert findKey(10) == 'Not Found'
</pre></p>
<p><a href="http://asoftwareguy.com/" target="_blank">My friend</a> says that I should also put equivalent Java code to lighten up readers&#8217; minds <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . So here goes &#8230;</p>
<p><pre class="brush: java;">

HashMap&lt;String, List&lt;Integer&gt;&gt; mapOfListValues = new HashMap&lt;String,List&lt;Integer&gt;&gt;() {
{
put(&quot;a&quot;, Arrays.asList(1,2));
put(&quot;b&quot;, Arrays.asList(3,4));
put(&quot;c&quot;, Arrays.asList(5,6));
put(&quot;d&quot;, Arrays.asList(7,8));
}
};

public String findKey(...) {
blah blah, iterator, find, check if rest of world is not null,  catch exceptions and then a lot of code goes here
}
</pre></p>
<p>Yawn&#8230; you get the point..</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/224/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=224&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2011/12/10/groovy-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>
	</item>
		<item>
		<title>Groovy #3</title>
		<link>http://vasya10.wordpress.com/2011/12/01/groovy-3/</link>
		<comments>http://vasya10.wordpress.com/2011/12/01/groovy-3/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 04:27:59 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=219</guid>
		<description><![CDATA[Multiple return values from a method One of the nicer features of Groovy is the ability to return multiple return values from a method via an implicit List and mapping them automatically to variables in the same order. While iterator methods are very useful in Groovy, you have access only to the current &#8220;it&#8221; object [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=219&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Multiple return values from a method</h3>
<p>One of the nicer features of Groovy is the ability to return multiple return values from a method via an implicit List and mapping them automatically to variables in the same order.</p>
<p>While iterator methods are very useful in Groovy, you have access only to the current &#8220;it&#8221; object within an iterator closure. There are times you may need access to a previous and next values too, just like in a Doubly LinkedList. Here is a smart closure that demonstrates meta programming technique (ie dynamically adding a method to java.util.List), multi-return values and iterators.</p>
<p><pre class="brush: groovy;">

//create a [prev,current,next] list triplet from an array
List.metaClass.triplet = { i -&gt; delegate.size() &lt;= 0 ? [null,null,null] : i == 0 ? [null, delegate[i], (delegate.size()&gt;1) ? delegate[i+1] : null] : (i==delegate.size()) ? [(i&lt;1) ? null : delegate[i-1]] : [delegate[i-1], delegate[i], delegate[i+1]] }
</pre></p>
<p>Usage:</p>
<p><pre class="brush: groovy;">

def list = [1,2,3,4,5,6,7,8,9,10]
for (int i=0; i&lt;list.size(); i++) {
def (prev, current, next) = list.triplet(i)
}

</pre></p>
<p>This will print the following output:</p>
<p><pre class="brush: groovy;">

[null,1,2]
[1,2,3]
...
[9,10,null]

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/219/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=219&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2011/12/01/groovy-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>
	</item>
		<item>
		<title>Groovy #2</title>
		<link>http://vasya10.wordpress.com/2011/11/10/groovy-2/</link>
		<comments>http://vasya10.wordpress.com/2011/11/10/groovy-2/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 04:30:00 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=209</guid>
		<description><![CDATA[Reading Json http response The http-builder library is pretty useful to create http requests and responses in groovy. I was initially a bit surprised that groovy does not have this functionality built-in and had to import a separate jar. Anyway I was trying to read a json response from the http-builder project website and the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=209&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h4>Reading Json http response</h4>
<p>The http-builder library is pretty useful to create http requests and responses in groovy. I was initially a bit surprised that groovy does not have this functionality built-in and had to import a separate jar.</p>
<p>Anyway I was trying to read a json response from the http-builder project website and the recommended sample did not work for some reason. This post provides a simple alternative.</p>
<p>Original (non-working) code</p>
<p><pre class="brush: groovy;">
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*

def url = &quot;http://www.url.com&quot;
def path = &quot;/path/resource&quot;
def outputFile = &quot;c:/temp/result.json&quot;
def params = [one:1, two:2]

def httpBuilder = new HttpBuilder(url)
httpBuilder.request(GET, JSON) {
uri.path = path
uri.query = params //parameters passed to the url -&gt; ?one=1&amp;two=2

headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'
response.success = { resp, json -&gt;
println resp.statusLine
outputFile.withWriter('UTF-8') { out -&gt; out.println json }
}
}
</pre></p>
<p>The above code reads the json file, but if you open the json file in firefox with the JSONView plugin, you may get a &#8220;json is invalid&#8221; error.</p>
<p>Solution:</p>
<p>The updated solution is to read the response as a text and apply &#8216;application/json&#8217; content type.</p>
<p><pre class="brush: groovy;">

 def httpBuilder = new HttpBuilder(url)
 httpBuilder.request(GET, TEXT) {
  uri.path = path
  uri.query = params

  headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'
  headers.Accept = 'application/json'
  response.success = { resp, json -&gt;
   println resp.statusLine
   outputFile.withWriter('UTF-8') { out -&gt; out.println json.text }
  }
}

</pre></p>
<p>With 1.8.3 release and built-in json support, this seems to be even easier now, though does not seem to be much fine-tuning of response success and failures.</p>
<p><pre class="brush: groovy;">

def params = [one:1, two:2, three:3]
def paramString = query.collect { &quot;$it.key=$it.value&quot; }.join(&quot;&amp;&quot;)
def url = site + path + &quot;?&quot; + paramString
def jsonResult = new URL(url).text

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/209/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=209&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2011/11/10/groovy-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>
	</item>
		<item>
		<title>Inconspicuous SharePoint Quirks #4</title>
		<link>http://vasya10.wordpress.com/2011/08/04/inconspicuous-sharepoint-quirks-4/</link>
		<comments>http://vasya10.wordpress.com/2011/08/04/inconspicuous-sharepoint-quirks-4/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 17:05:43 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[Sharepoint 2010]]></category>
		<category><![CDATA[0x80070005]]></category>
		<category><![CDATA[access_denied]]></category>
		<category><![CDATA[identity impersonator]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[system.directoryservices]]></category>
		<category><![CDATA[windows server 2008 r2 sp1]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=202</guid>
		<description><![CDATA[Mystery of the Identity Impersonator This one is not exactly a SharePoint quirk, but a SharePoint app led me to it. Which means its an IIS quirk. Or a .Net quirk. Or a Service Pack quirk. Or a Windows Server 2008 quirk. Or a Microsoft quirk. Or whatever&#8230; My co-worker had written a form-based-authentication login [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=202&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Mystery of the Identity Impersonator</h2>
<p>This one is not exactly a SharePoint quirk, but a SharePoint app led me to it. Which means its an IIS quirk. Or a .Net quirk. Or a Service Pack quirk. Or a Windows Server 2008 quirk. Or a Microsoft quirk. Or whatever&#8230;</p>
<p>My <a href="http://acveer.wordpress.com/" target="_blank">co-worker</a> had written a form-based-authentication login page for a SharePoint application. The users are created in Active Directory and the usual frills of user account &#8211; login, security questions, change password, reset password et al.</p>
<p>The app worked fine in dev environment, was working fine in Stage but one fine Monday, broke in Stage. The user was created in the AD, but was set in a disabled state and returned an error back to the application. It was working in Dev fine though. The web.config, wsp solution, content databases are all exactly same between dev and stage. The only difference was the stage environment had Windows Server 2008 R2 SP1, while the Dev was not. We decided to backout SP1 from stage and lo, it started working again. Could it be the sheer gravitons of SP1 cause to distort the user creation in the Active Directory?</p>
<p>Since SP1 was causing the problem, we got the dev environment to the same SP1 patch level as stage. And yes, the user creation broke. Repeatable bugs are like flights crashing without casualties. Yeah, it crashed, but no one died. I started looking at the ULS and noticed there were no log statements. Coming from the Java world, I rely more on debug statements rather than run-time debugging. A friend of mine reminds me that in the .Net world programmers first put the solution in Debug mode, then start writing the code. But here the log statements were there in the code, yet were not written.</p>
<p>You can spot the issue here:</p>
<p><pre class="brush: csharp;">
public static class ExceptionExtension {
public static string Unroll(this Exception ex) {
if (ex == null) return &quot;&quot;;
string exStr = ex.Message + &quot;\n&quot; + ex.StackTrace;

if (ex.InnerException != null) {
exStr += &quot;\n&quot; + ex.InnerException.Unroll();
}

return exStr;
}

Test Usage:
PortalLog.LogString(&quot;ERROR: {0} || [{1}]&quot;, errorMessage, ExceptionExtension.Unroll(ex));
</pre></p>
<p>The above code wont work, because the correct usage of the extension is ex.Unroll(), not by a static method call. Once I fixed this, I could see the actual errors in ULS.</p>
<p>Here is how the account was being created usig LDAP:</p>
<p><pre class="brush: csharp;">
entry = new DirectoryEntry(ldapPath, ldapUser, ldapPassword, AuthenticationTypes.Secure);
//create new user object and write into AD
user = entry.Children.Add(&quot;CN=&quot; + samAccountName, &quot;user&quot;);
user.Properties[&quot;userprincipalname&quot;].Add(emailAddress);
user.Properties[&quot;samaccountname&quot;].Add(samAccountName);
//...
user.CommitChanges();
user.Invoke(&quot;SetPassword&quot;, password);
user.Invoke(&quot;Put&quot;, new object[] { &quot;userAccountControl&quot;, &quot;512&quot; });
</pre></p>
<p>System.DirectoryServices threw exception with an error code 0&#215;80070005 (ACCESS_DENIED) while invoking SetPassword. I double checked that the ldapUser has identical permissions in dev and stage. How can the user be created but still access denied? More importantly, WHO is being denied? Certainly not the ldapUser.</p>
<p>I added the debug for WindowsIdentity.GetCurrent().GetName(). And it returned NT AUTHORITY\IUSR. In IIS, the anonymous access is enabled and in the web.config the identity tag is</p>
<p><pre class="brush: xml;">
&lt;identity impersonator=&quot;true&quot;/&gt;
</pre></p>
<p>Obviously IUSR does not have permission to set the password. But why was it working in dev, before SP1? When I tried in another environment without SP1, the current Windows Identity was the same as the Application Pool user for that SharePoint Web Application and not the IUSR. Google-o! Er.. I mean, Bing-o!</p>
<p>Back to dev with SP1, I set the impersonator to false, and now I saw the current identity as the Application Pool user! W2k8 R2 without SP1 was not respecting the identity impersonator flag. Obviously without SP1, the IUSR anonymous user was having access to create an user in active directory, while SP1 prevented it. The impersonation is not required when you are creating user using the ldap service user and password, who already have access.</p>
<p>To me it looks like a security hole (pre-SP1). I could not find any online documentation or release notes mentioning about this. If you know of such documentation, please drop a comment!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/202/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=202&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2011/08/04/inconspicuous-sharepoint-quirks-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>
	</item>
		<item>
		<title>Inconspicuous SharePoint Quirks #3</title>
		<link>http://vasya10.wordpress.com/2011/08/02/inconspicuous-sharepoint-quirks-3/</link>
		<comments>http://vasya10.wordpress.com/2011/08/02/inconspicuous-sharepoint-quirks-3/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 18:20:01 +0000</pubDate>
		<dc:creator>vasya10</dc:creator>
				<category><![CDATA[SharePoint 2007 to 2010 Migration]]></category>
		<category><![CDATA[Sharepoint 2010]]></category>
		<category><![CDATA[missing content type column]]></category>

		<guid isPermaLink="false">http://vasya10.wordpress.com/?p=188</guid>
		<description><![CDATA[Mystery of the missing Content Type column Is there something called &#8220;Over-architecting a solution&#8221;? Or do some people get carried away too much by Object Oriented Concepts that a simple if-else condition is enshrined into a dazzling hierarchy of classes, interfaces and er.. content types? SharePoint&#8217;s answer to creating a class/type or pseudo-interface is the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=188&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Mystery of the missing Content Type column</h2>
<p>Is there something called &#8220;Over-architecting a solution&#8221;? Or do some people get carried away too much by Object Oriented Concepts that a simple if-else condition is enshrined into a dazzling hierarchy of classes, interfaces and er.. content types? SharePoint&#8217;s answer to creating a class/type or pseudo-interface is the Content Type. While a powerful feature, there are times even the Microsoft Team gets confused what to do with it, unconsciously bury a feature and consciously let it go undocumented.</p>
<p>There was a requirement to show different banners with different styles based on items in the &#8220;Banner List&#8221;. The different banner types were represented as &#8220;Content Types&#8221; and so the end user will create Banner Type 1, Banner Type 2 etc; set it to active and it would appear on the web page. The solution was designed in such a way that a calculated column in that list was populated based on the content type of the banner. That is, the calculated column had a formula in the BannerText sitecolumn:</p>
<p><pre class="brush: plain;">

=IF [Content Type] == &quot;Banner Type 1&quot; Then BannerText = &quot;Red Banner&quot; ELSE IF [Content Type] == &quot;Banner Type 2&quot; Then BannerText = &quot;Blue Banner&quot; ELSE IF...

</pre></p>
<p>The site column was relying on the Content Type of the list, that will be known at runtime. And that was working perfectly fine. In SharePoint 2007, that is.</p>
<p>Over to 2010. When I was trying to add a new item in that list, the calculated column Text would populate with a value &#8220;#NAME?&#8221; indicating that there is something wrong with the formula. Going back the site column, initially said the formula is fine, but when I tried to update it, errored out saying invalid column. Upon inspection, I see that Content Type is missing in the &#8220;Insert Columns&#8221; list.</p>
<p><a href="http://vasya10.files.wordpress.com/2011/08/sharepoint-2007-ct.png"><img title="sharepoint 2007 ct" src="http://vasya10.files.wordpress.com/2011/08/sharepoint-2007-ct.png?w=300&#038;h=132" alt="" width="300" height="132" /></a></p>
<p>First I thought my migration was wrong. Looked back at the SharePoint 2007 implementation, the &#8220;Content Type&#8221; column is there (see above image from MOSS 2007)! So Microsoft Team couldn&#8217;t handle the power the Content Types and removed it, I guess. But why was it removed? (see image below, from SharePoint 2010)</p>
<p><a href="http://vasya10.files.wordpress.com/2011/08/sharepoint-2010-ct.png"><img class="alignnone size-medium wp-image-187" title="sharepoint 2010 ct" src="http://vasya10.files.wordpress.com/2011/08/sharepoint-2010-ct.png?w=300&#038;h=126" alt="" width="300" height="126" /></a></p>
<p>The _layouts/fldnew.aspx page inherits from Microsoft.SharePoint.ApplicationPages.BasicFieldEditPage. The method that creates the Insert Columns is WriteFieldNamesForFormulaColumnPicker(), so I loaded the .Net Reflector and inspected the code.</p>
<p><pre class="brush: cpp;">
protected internal static void WriteFieldNamesForFormulaColumnPicker(TextWriter output, SPFieldCollection fields, string currentDisplayName)
 {
 SortedList list = new SortedList(new Comparer(fields.Web.Locale), fields.Count);
 foreach (SPField field in fields)
 {
 if ((((!(field is SPFieldText) &amp;&amp; !(field is SPFieldCalculated)) &amp;&amp; (!(field is SPFieldNumber) &amp;&amp; !(field is SPFieldDateTime))) &amp;&amp; (!(field is SPFieldChoice) || (field is SPFieldWorkflowStatus))) &amp;&amp; (!(field is SPFieldBoolean) || (field is SPFieldAllDayEvent)))
 {
 continue;
 }
 if (((field.InternalName != &quot;_UIVersionString&quot;) &amp;&amp; !field.Hidden) &amp;&amp; (field.Title != currentDisplayName))
 {
 list.Add(field.Title + &quot;_&quot; + field.InternalName, field);
 }
 }
 bool flag = true;
 foreach (SPField field2 in list.Values)
 {
 string title = field2.Title;
 SPHttpUtility.NoEncode(&quot;&lt;option value=\&quot;[&quot;, output);
 SPHttpUtility.HtmlEncode(title, output);
 SPHttpUtility.NoEncode(&quot;]\&quot;&quot;, output);
 if (flag)
 {
 SPHttpUtility.NoEncode(&quot; selected=\&quot;selected\&quot;&quot;, output);
 flag = false;
 }
 SPHttpUtility.NoEncode(&quot;&gt;&quot;, output);
 SPHttpUtility.HtmlEncode((title.Length &gt; 20) ? (title.Substring(0, 20) + &quot;...&quot;) : title, output);
 SPHttpUtility.NoEncode(&quot;&lt;/option&gt;&quot;, output);
 }
 }

</pre></p>
<p>So if the field is only one of text, calculated, number, datetime, choice, workflowstatus, boolean it is available for formulas. So what type is the Content Type column anyway? Using Powershell, we can determine that &#8211;</p>
<p><pre class="brush: powershell;">
PS C:\Users\spfarmadmin&gt; $w.Fields[&quot;Content Type&quot;]

EnableLookup                : False
FieldRenderingControl       : Microsoft.SharePoint.WebControls.ComputedField
FieldRenderingMobileControl : Microsoft.SharePoint.MobileControls.SPMobileComputedField
FieldTypeDefinition         : Microsoft.SharePoint.SPFieldTypeDefinition
TypeDisplayName             : Computed
</pre></p>
<p>So since the field is Computed type, it does not appear in the insert column list. The same code in SharePoint 2007 didn&#8217;t have this restriction. So there is no way to find content type from within a site column. So I had to redesign the list now. Instead of multiple content types, I just added a new dropdown column which contain a list of values which was exact same as the content type. That way the functionality still worked without changing the underlying custom code. So a list with several content types and calculated columns to determine a text could be replaced with a simple dropdown list! Instead of multiple content types and formulas.</p>
<p>But a fundamental feature was removed. May be the next release of SharePoint 2014 will not have content databases?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vasya10.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vasya10.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vasya10.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vasya10.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vasya10.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vasya10.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vasya10.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vasya10.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vasya10.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vasya10.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vasya10.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vasya10.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vasya10.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vasya10.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vasya10.wordpress.com&amp;blog=2242965&amp;post=188&amp;subd=vasya10&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vasya10.wordpress.com/2011/08/02/inconspicuous-sharepoint-quirks-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bc58b21652f5f4a2120e5a0be3723399?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vasya10</media:title>
		</media:content>

		<media:content url="http://vasya10.files.wordpress.com/2011/08/sharepoint-2007-ct.png?w=300" medium="image">
			<media:title type="html">sharepoint 2007 ct</media:title>
		</media:content>

		<media:content url="http://vasya10.files.wordpress.com/2011/08/sharepoint-2010-ct.png?w=300" medium="image">
			<media:title type="html">sharepoint 2010 ct</media:title>
		</media:content>
	</item>
	</channel>
</rss>
