Posts Tagged ‘SharePoint’

Use Custom CSS in MOSS RadEditor

November 17th, 2009 Comments off

Telerik’s MOSS RadEditor is a great editor, especially if you are concerned about accessible html outputs. If you are using MOSS RadEditor, you might notice that it doesn’t pick your custom styles at edit time. Reason is by default it uses this style file “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\wpresources\RadEditorSharePoint\\RadControls\Editor\Skins\Default2006\EditorContentArea.css”. You have two options one you can edit this file and add your style here.

Second option is that you can set the css file by using the property “CssFiles” in ConfigFile.xml or ListConfigFile.xml depends on your configuration. For example you are deploying your CSS files in below folder structure under layouts folder.


your entry in config files will be like this.

<property name=CssFiles><item>/_LAYOUTS/MyWebFiles/css/editor_style.css</item></property>


Categories: MOSS Tags: , , ,

SharePoint Warmup Scripts – Scheduled

November 2nd, 2009 Comments off

It’s very common that when you start any SharePoint site early in the morning, you find it very slow. I know a lot of organizations are very annoyed by this behavior. Normally IIS discard it’s cache overnight, so in the morning first request rebuild the web application again. This make first request very slow. This is an amazing script, it will seek out every site and site collection on a sharepoint server, going as deep as you like, and send them an HTTP request, so that the site remains in cache.

I don’t take credit for this script, I picked this from (Thanks to A Kennel), and this project was inspired from SharePoint warmup scripts at : .

For this script you need to consider a few things, first of all STSADM should be in path. I used Windows 2008, so here you can see how to add STSADM in your path using Windows 2008. Attached file contains 4 files. startup.cmd, spwakeup.exe, sites.conf and Program.cs.

The exe (spwakeup.exe) from A Kennel recognizes 3 option switches:
-depth:X –specifies how many levels deep to search for sites. If you do not set anything, the default value of 3 is used.
-site:XXX.XXX — specifies the starting URL. If you do not set anything, the app looks for sites.conf, and uses the sites listed there. If sites.conf does not exist, the default URL http://localhost is used.
-log:Filename — specifies a log file to record the results. If a file is not specified, the log will be displayed on the console.

This is the example that how yout startup.cmd will look like

“c:\SPWarmupServer\SPWakeUp” -depth:5 -log:c:\SPWarmupServer\logs.txt -site:

Now here you can see how you can schedule a script in windows server 2008. By using this post you can schedule your script to a suitable time for daily call. It could be 4:00 am. It will give site a boosting effect.


Categories: MOSS Tags: , ,

Implementing CAPTCHA in SharePoint sites

October 7th, 2009 36 comments


A CAPTCHA is a program that can generate and grade tests that humans can pass but automated programs cannot. For example, humans can read distorted text as the one shown below, but automated programs can’t.


The term CAPTCHA (for Completely Automated Turing Test to Tell Computers and Humans Apart) was coined in 2000. CAPTCHA is very useful in current applications. Below are some of the applications of CAPTCHA.

  • Preventing Comment Spam in Blogs
  • Protecting Website Registration
  • Online Polls
  • Preventing Dictionary Attacks
  • Search Engine Bots
  • Worms and Spam

There are different types of CAPTCHA programs available on the internet, but all of them are not the same in their usability and implementation. Here are some examples.









When you start your search to implement CAPTCHA program in your site, you should consider a following items.

  • CAPTCHA should be compatible with your existing implementation. CAPTCHA programs are available for PHP, ASP .Net, Perl, Java and many other environments. Like for SharePoint I choose ASP .Net CAPTCHA.
  • It shouldn’t be very simple. Because if it generates a very simple image, using the same font and style, there is a huge chance that automated image processing programs can read it. Then it’s useless. It should be complex enough for smart hackers.
  • The scripts used to create CAPTCHA program should be secured and the system shouldn’t have loop holes for hackers. Common examples of insecurities in this respect include: (1) Systems that pass the answer to the CAPTCHA in plain text as part of the web form. (2) Systems where a solution to the same CAPTCHA can be used multiple times (this makes the CAPTCHA vulnerable to so-called “replay attacks”).
  • There are a lot of text based CAPTCHA programs in the market, like mathematical questions. These are very easy calculations for automated scripts and break easily.
  • One very important thing CAPTCHA should be accessible.  There should be support for impaired users to access it. There are CAPTCHA programs in the market with audio support.

After considering all the above mentioned factors I have selected reCAPTCHA. It has support for ASP .Net, complex to break, provides secure implementation, accessible and major thing it is free to use for any website. You can even change the look and feel of reCAPTCHA control.

Implementation in SharePoint

In order to use reCAPTCHA in your web site you need to get a new key from reCAPTCHA website ( For this you need to signup to the site and then you can get a key against your domain name. Your reCAPTCHA key will be valid for the specified domain and all sub-domains. If you like to use reCAPTCHA for other domains, you need to get more keys or you can select global key to use cross domain.

You can download the reCAPTCHA dll from this link , this dll is for ASP .Net implementations. The latest version available is Now you can deploy reCAPTCHA to local bin for the web site or in GAC as well.

In order to deploy it in GAC, you need to do some more steps. You need strongly named dll for GAC. In this case you already have a dll and it is not strongly named. But there is nothing serious worries you can change it into a strongly named dll. Here are some simple steps.

  • Get the MSIL from the dll
    • Open visual studio command prompt and enter the following command
    • ildasm Recaptcha.dll /out:
    • Rename the original dll file
      • Use this command
      • Rename Recaptcha.dll Recaptcha_org.dll
      • Create a snk (key) file
        • Sn –k Recaptcha.snk
        • Create strongly named dll from MSIL and key files
          • ilasm /dll /key= Recaptcha.snk

That’s all, now your file is ready to deploy in GAC. Deploy it in GAC. You can use below ‘gacutil’ command or simply drag and drop to assembly folder (usually the path is C:\windows\assembly).

  • Gacutil –l “path to dll”

Now you need to add the reCAPTCHA control to safe control list in web.config. This entry will be like this

<SafeControl Assembly=Recaptcha, Version=, Culture=neutral, PublicKeyToken=9c9a3ef27e62a14a Namespace=Recaptcha TypeName=* Safe=True />

Add the reCAPTCHA control on the page, where you want to use it.

<%@ Register Tagprefix=Recaptcha Namespace=Recaptcha Assembly=Recaptcha, Version=, Culture=neutral, PublicKeyToken=9c9a3ef27e62a14a %>

Finally insert the reCAPTCHA control under the form tag.

ID=idAntiBotReCAPTCHA runat=server Theme=clean

This is how it will look like in SharePoint page.



Reference links.



Categories: MOSS Tags: ,

Using SharePoint site Navigation to a non-SharePoint website

October 5th, 2009 Comments off

It was a very interesting task we had from one client. We had developed a publishing internet site for the same client. This client has a non SharePoint site, somehow this non SharePoint site has a relation with SharePoint site and client wanted to provide an option to navigate to other site from publishing SharePoint site. The interesting thing was client wanted to have the same look and feel for other site as of SharePoint site, specially client wanted to have the same left navigation. So when users navigate from SharePoint site to non SharePoint site they don’t get the feeling that now they are on a different website.

We have tried to think in different ways to implement this option. But there was no straight forward way to use the SharePoint navigation in a non SharePoint site. After giving it some thought we suggested something pretty simple, which looked difficult in initial talks.

We have created a web service, which interact with SharePoint. This web service actually makes a request to the same page from SharePoint website, from where we have to use the left navigation. Then it grab the whole html and use xpath to extract the div with navigation part. It just return this extracted html as xml.
Now we call this web service from the non SharePoint website and fill the left part with returned div from web method used in web service. It seems pretty simple 
We used the same technique to change the whole look and feel for the non SharePoint site to match the SharePoint site. And it worked great.

Here is the piece of code from web service.

[WebMethod(Description = "pageType should be one of pre-defined page type.")]

public XmlDocument GetLeftNavigation(string pageType)


  XmlDocument oDoc = new XmlDocument();


  string html = “”;

  if (ConfigurationManager.AppSettings[pageType] != null)


    string url = ConfigurationManager.AppSettings[pageType];

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

    request.Method = “GET”;

    request.Credentials = CredentialCache.DefaultCredentials;

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();




      if (response.StatusCode == HttpStatusCode.OK)


        // get the response stream.

        Stream responseStream = response.GetResponseStream();

        // use a stream reader that understands UTF8

        StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);



          html = reader.ReadToEnd();

          html = html.Substring(html.IndexOf(“<div id=\”nav-y\”>”));

          html = html.Remove(html.IndexOf(“</li></ul></div>”) + 16);


          if (oDoc.GetElementsByTagName(“a”).Count > 0)


            string siteUrl = ConfigurationManager.AppSettings["webpath"];

            foreach (XmlNode oNode in oDoc.GetElementsByTagName(“a”))


              string href = oNode.Attributes["href"].Value;

              href = siteUrl + href.Substring(1);

              oNode.Attributes["href"].Value = href;




        catch (Exception ex) { }



          // close the reader










  return oDoc;


Hope you will like it.


Categories: MOSS Tags: , ,

Caching in the SharePoint BaseFieldControl

August 5th, 2009 Comments off

This is definitely a new thing for me Today. We had some issue in a page title control on a SharePoint site. This is a simple SharePoint BaseFieldControl, we are using to display the page title on different pages. This control is relying on query string values. The issue I was looking for is ‘Page title is not changing on different pages for different query string values’.

When I have started debugging this control, I have noticed that it is ignoring query string value sometimes. Seems some caching is on. But there was no caching on from the developer. After some playing around I reached to the problem. BaseFieldControl by default do caching for displaying html, and for this it has a property name ‘CanCacheRenderedFieldValue’. The default value for CanCacheRenderedFieldValue is true.  

To resolve it I simply override the OnInit method and set the value for CanCacheRenderedFieldValue to false. It sorted out the ambiguous problem.

Hope you have enjoyed it.