This blog is moved to

Friday, October 22, 2010

MOSS | Using WSPBuilder for Creating a List Instance

In this post I am going to explain how we can make use of WSPBuilder for creating a List instance.
First we need to install SharePoint Solution Generator. You can download the same from here
Now follow the steps for generating List Definition. Here I am going to create a List Definition of a List named “Configurations”
Start SharePoint solution generator
Select List Definition and click on Next button
Specify the Site Url where the list is present and click Next
Select the List and click Next
Provide a project name and path, then click Next
Click Finish
Before clicking Exit, click “Click here to open the generated solution” and click Exit
You can see the “Configurations” folder. Let it be opened. Now open visual studio and create a WSPBuilder project
Once the project is created, add a new blank feature
Now, copy the folder “Configurations” and paste it under the feature folder as shown below
Open the ListDefinition.xml file and copy the following content
Once the content is copied, paste it in the elements.xml file as shown below and delete the file "ListDefinition.xml" from visual studion project
You can also see ListInstance, make a similar entry in your elements.xml file. Also replace the FeatureId with the FeatureId specified in the feature.xml file
Now build the wsp, deploy it and activate the feature. This will add the list to the site.
Hope this was helpful!!!

Thursday, October 21, 2010

MOSS | Using People Editor Control

People editor can be used whenever we want the user to select user, AD groups or SharePoint groups. For using the control, 1st we need to register the assembly as shown below
<%@ register tagprefix="SharePointWebControls" namespace="Microsoft.SharePoint.WebControls"
assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
Once this is done, we can use the following tag for placing the control
<SharePointWebControls:PeopleEditor ID="ppeUser" runat="server" Rows="1" 
CheckButtonImageName = "/_layouts/Images/user.png" 
BrowseButtonImageName = "/_layouts/Images/addressbook.png"                                   
PlaceButtonsUnderEntityEditor="false" MultiSelect="false" AutoPostBack="true"/>

In C#, the following code demonstrate the usage


Using the above code we can get information user has selected/entered in the people editor control.

public static void UpdatePeoplePicker(string login, PeopleEditor editor)
ArrayList list = new ArrayList();
PickerEntity entity = new PickerEntity();
entity.Key = login;
entity = editor.ValidateEntity(entity);

The above code can be used to update the People Editor control using code.

We can restrict the selection of the People Editor using the SelectionSet property. It accepts the following values

User – In case the selection to be restricted only for users
AD – In case the selection to be restricted only for AD groups
SPGroup – In case the selection to be restricted only for SharePoint Groups

Hope this was helpful!!!

Friday, October 8, 2010

MOSS 2007 | Enumerate User Profile Properties

Below is the code to enumerate the User Profile Properties

using System;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;

namespace ConsoleApplication1
class Program
static void Main(string[] args)
using (SPSite site = new SPSite("http://server:port/"))
ServerContext context =
UserProfileManager profileManager = new UserProfileManager(context);
string sAccount = "domain\\user";
UserProfile u = profileManager.GetUserProfile(sAccount);
PropertyCollection props = profileManager.Properties;

foreach (Property prop in props)
Console.WriteLine(prop.DisplayName + ">>" + prop.Name );