Thursday, December 22, 2011

Unable to get List data present in Claims Based Web Application

Hi All,

Recently we faced the problem of not able to pull data that is present in Windows Authenticated Web Application from a Claims Based Web Application. These two web apps are on same server.

Tried all possible ways like LINQ to SharePoint, Client Object Model, 2007 lists.asmx etc. but no luck

Finally, we have added a registry key called "DisableLoopBackCheck" and set its value to 1.

More information on this can be found here

Cheers !

Tuesday, December 20, 2011

Read Credentials from Secure Store Service Programatically in SharePoint 2010


If you want to read the credentials set in secure store service programatically, then the below code is helpful.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.Runtime.InteropServices;
using System.Security;
using Microsoft.BusinessData.Infrastructure.SecureStore;
using Microsoft.Office.SecureStoreService.Server;

namespace ReadSecureStoreCredentials
    public static class SecureStoreUtils
        public static Dictionary<string, string> GetCredentials(string applicationID)
            var credentialMap = new Dictionary<string, string>();
                SPSite site = SPContext.Current.Site;
                SPServiceContext serviceContext = SPServiceContext.GetContext(site);
                var secureStoreProvider = new SecureStoreProvider { Context = serviceContext };
                using (var credentials = secureStoreProvider.GetCredentials(applicationID))
                    var fields = secureStoreProvider.GetTargetApplicationFields(applicationID);
                    for (var i = 0; i < fields.Count; i++)
                        var field = fields[i];
                        var credential = credentials[i];
                        var decryptedCredential = ToClrString(credential.Credential);

                        credentialMap.Add(field.Name, decryptedCredential);
            return credentialMap;

        public static string ToClrString(this SecureString secureString)
            var ptr = Marshal.SecureStringToBSTR(secureString);

                return Marshal.PtrToStringBSTR(ptr);

Make sure you have added the following dll's

1. Microsoft.Office.SecureStoreService.dll located at C:\Windows\assembly\GAC_MSIL\Microsoft.Office.SecureStoreService\\Microsoft.Office.SecureStoreService.dll and

2. Microsoft.BusinessData.dll located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.BusinessData.dll

And here is how you make use of the above code to read credentials from secure store service

Dictionary<string, string> SSCredentials = SecureStoreUtils.GetCredentials("SecureStoreId");
string strDU = SSCredentials.ElementAt(0).Value;
int SlashPos = strDU.IndexOf('\\');
this.strDomainName = strDU.Substring(0, SlashPos);
this.strUserName = strDU.Substring(SlashPos + 1, strDU.Length - this.strDomainName.Length - 1);
this.strPassword = SSCredentials.ElementAt(1).Value;

Bye for now :)

Saturday, December 10, 2011

Error occurred in deployment step 'Recycle IIS Application Pool': A timeout has occurred while invoking commands in SharePoint host process.


We got the below error while trying to deploy SharePoint solution

Error occurred in deployment step 'Recycle IIS Application Pool': A timeout has occurred while invoking commands in SharePoint host process.

Thr possible reasons for this error as per MSDN forums are:

1. Less System Resources, possible <6 GB of RAM. (Recommended RAM for SP 2010 is >=6GB)

2. Application Pools might be stopped.

In my case, both these possibilities doesnot apply.

The solution to eliminate this error is:

Increase the Shutdown Time Limit and Startup Time Limit under Application Pool -> Advanced Settings.

This resolved the above error:)

Hidden SharePoint List - User Information

Hello Again,

There is a hidden list in SharePoint which stores the User Details like Name, Email, Login Name etc.

We can access this list using the URL:


Here, when ever a new user is added to the sharepoint site, firstly that user will be added to this list. Hence, we can consider this list as a resource of all users present in the site.

We can acess this list through object model as:

SPList hiddenUserList = SPContext.Current.Web.SiteUserInfoList; 

Note that this list contains the users which are deleted from Active Directory too. Hence, whenever we delete a user from SharePoint site, its actually a soft delete and that user details still exist in this hidden list.

SharePoint Rocks !!!

Get User Details by ID in SharePoint 2010


If you want to get the user details like Name, Email and other details of SharePoint user based on ID (Example: 12;domain\username), then the below code will be useful


Thursday, December 1, 2011

Windows Powershell Command Builder

Hello there,

Here is an useful tool from Microsoft called as "Windows Powershell Command Builder" which gives basic information about Powershell Commands. Thanks to my colleague for suggesting this tool :)

Windows Powershell Command Builder

There are two sections in this tool.

1. Verbs
2. Nouns

Verbs section contains all basic command names such as "Add", "Backup", "Install" etc.
Nouns section contains the target on which the verb acts. For example, Farm Solution, Sand box Solution, Site etc.

To use this tool, just drag one of the command in Verbs section and one of the command in Nouns section into Design Surface. Then, you will get a basic command. For example, Add-SPSolution etc.

Once you get the command, you can copy this command to Clipboard.

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters.

Hello Again !

We usually get this common error when trying to deploy a package containing files of length greater than 260 characters. VS 2010 showed this error in feature.

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters.

At first glance, the obvious solution which we feel is to reduce the file names in the solution. I tried the following approaches:

1. Reduced the file names in my solution especially the SharePoint Mapped Layouts Folder.
2. Changed the VS 2010 Project directory from C:\Users\saiabhilash\Documents\Visual Studio 2010\Projects to C:\MyProjects but got the same error !

OK! The resolution to this problem is to change the Deployment Path for the Feature. Double Click on the Feature and click F4 by selecting the feature. By Default, the Deployment Path for a features looks like this


We have deleted the First Portion of this string and modified the path as


With this change, we were able to get rid of the above error :)

Failed to instantiate file "Home.aspx" from module "SitePagesModule": The specified list does not exist

We have a module in our SharePoint 2010 VS project which deploys the custom aspx pages in site pages document library.

Whenever we try to deploy this project, we get the below error:

Failed to instantiate file "Home.aspx" from module "SitePagesModule": The specified list does not exist

The possible solutions to this problem can be:

1. Delete the Module which deploys the site pages and add them again
2. In Elements.xml of the SitePages Module, change the Type Attribute value from "GhostableInLibrary" to "Ghostable" as shown below
<File Path="SitePagesModule\Home.aspx" Url="Home.aspx" Type="Ghostable" IgnoreIfAlreadyExists="TRUE" />

This is it. Now, the above error stopped flashing again :)

Happy SharePointing !