Shed some light into SharePoint web part errors

Seeing many of those “descriptive” SharePoint errors like this one lately:

The “MyWebPart” Web Part appears to be causing a problem.
Web Parts Maintenance Page: Use this page to temporarily disable Web Parts or remove personal settings.
Troubleshoot issues with Windows SharePoint Services.

If you want to see more meaningful error description, do a simple trick. Change the following line in your SharePoint web.config into something like this:

<SafeMode MaxControls=”50″ CallStack=”true”>

Of course, make sure NOT to change this switch in your production environment, as it could reveal potentially sensitive information.

Active Directory or “How I Learnt to Live With the Ugly COM Guts”

In a project I’m working on, I have to authenticate a user on a custom SharePoint 2003 login form (Yes, that’s possible….more on it will be coming soon). It is a straightforward task, once you overcome the System.DirectoryServices namespace oddities.

In essence, I try to bind a user credentials to a Active Directory LDAP server. If successful, the account is active and with a valid password.

But, what happens when you have a user with “User must change password on the next logon” checkbox turned on? If you try to bind the user, LDAP will throw an error because the credentials you’ve supplied are not valid.

It was an imperative to be able to check for this condition. After a lot of googling, I’ve come out with the solution:

DirectoryEntry user;

System.Int64 largeInt = 0;

IADsLargeInteger int64Val = IADsLargeInteger) user.Properties[“pwdLastSet”].Value;

largeInt = int64Val.HighPart * 0x100000000 + int64Val.LowPart;

if(largeInt == 0)


// First login detected


Pretty much obfuscated, isn’t it?

It seems that Active Directory stores the “must change password” condition in a property called pwdLastSet, which also stores the date when the password was last set. If this value is zero, the password has not yet been set, ie “must change password” check is marked in the User Properties Tab.

But if you try to check the value directly, you’ll face a lot of exceptions from the underlying COM scaffolding. The pwdLastSet property is a 64-bit integer value which maps into a IADsLargeInteger type (found in “ActiveDs COM Type Library”). This type has two 32-bit halves: HighPart and LowPart. So, if you want to translate this into a large integer (System.Int64 in .NET Framework) you have to perform the multiplication shown in the code above.

A lot of headache could have been avoided if this strange quirk had been well-documented.

Ruby on Rails, the next tidal wave?

I’ve been looking for information about the new buzzword in town: Ruby on Rails (aka RoR). I thought it was just another web development framework, like Struts for instance.

I was wrong.

First of all, Ruby on Rails are two related technologies stitched together, namely Ruby and Rails.

Ruby is a fully-fledged object-oriented language. It has some of the elegance of Python, some of the power of Smalltalk and some spartainty of SML. It was developed in Japan in 1994, and in the last years it began to spread around the world. Ruby seems to follow natural (at least in English) order of words, so the code in Ruby is easy to follow, as much as I could see.

Check for yourself:

"gin joint".length

Rails is a database-backed web framework built with Ruby. It has full object-relational mapping support, AJAX handlers, auto-generated code and it implements a Model-View-Controller (MVC) paradigm. It relies heavily on reflection and metaprogramming.

So, what’s the sum of those two pieces of technology? Ruby on Rails, claimed to be “the most productive web development framework so far“.

Is it so? I am a born skeptic, so I paid more careful visit to the tutorials and other documentation available on the RoR site.

I’m still perusing it, but I’m impressed. RoR allows you to use scaffolding, or code generated by default, to have a working CRUD application while you build your own features. Then, you just remove the scaffolding, much like when building a house.

The productivity of RoR is what shocked me: the flagship application of Rails, Basecamp, is a full project collaboration portal (SharePoint Light, I’d say). It was build by a single developer in two months and contains a mere 4.000 lines of code.