DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Posts Tagged ‘PeopleEditor’

How to access the MOSS UserProfile through the ProfileManger

Posted by PANVEGA on November 7, 2008

To those doing software development for a Sharepoint environment, user profiles can be a mysterious and confusing area. This post will detail some of the basics, and outline some snafoos you may run into if you find yourself doing software development that interacts with the Sharepoint user profile information.

First, it should be explained that the user profile setup differs depending on whether you are operating in a full MOSS environment, or simply using the basic WSS structure. In the full MOSS environment, user profile information is stored in a central database, and profile information is shared across site collections that may be hosted on your server. This profile info can be read and/or edited via the UserProfileManager class within the Microsoft.Office.Server dll.

Read a little deeper about Profiles administration in more in one of my previous posts

Read the rest of this entry »


Posted in Administration, Field Types, Infrastructure, MOSS | Tagged: , , , | 1 Comment »

Custom SharePoint People Picker

Posted by PANVEGA on February 22, 2008

In this example I wanna show you how to customize the SharePoint people picker in a custom webpart with some additional controls.

SharePoint provides a control known as a “people picker” that allows users to search for and select users defined at some specified scope. This control is normally associated with Personnel field in a SharePoint List.

The control is actually called a “PeopleEditor” and is in the ‘Microsoft.SharePoint.WebControls‘ namespace. You will need to add a reference to ‘Microsoft.Sharepoint.dll’ to your project in Visual Studio, which is something you probably already have if you are writing anything that works with SharePoint.

Here’s a list of the people picker properties that can be set ()



The People Picker can only do wildcard searches for AD Windows group names. With any role provider other than the out of the box AD one the role provider lookup is specific to the entire name. For example if you have a group called “Readers” and you enter “Read” in the People Picker search dialog, it will not find your group; if you enter “Readers” it will. The role provider doesn’t provide a good way to do wildcard group search. See “Multiple Auth Providers” for more info. As well Steven Fowler in figuring out a custom membership provider has some great insights, another post People Picker and Custom Membership provider has dev insights on the GetUser() method.

The code creates three controls – a PeopleEditor (from the Microsoft.SharePoint.WebControls namespace), a button and a textbox. The button has an click event that itirates over the users picked in the PeopleEditor and writes them to the text box for instance with a stringbuilder. However you can add any control you are looking for.

First, create a custom webpart in visual studio. Read my post first develope-a-custom-webpart-in-moss.

Read the rest of this entry »

Posted in DotNet, MOSS, WebParts | Tagged: , , , | 2 Comments »

Getting user login from the PeopleEditor via Code

Posted by PANVEGA on February 1, 2008

Assuming you have a people editor control defined like below:

<wssawc:PeopleEditor AllowEmpty=”false”  ID=”myPeopleEditorControl” runat=server SelectionSet=”User” MaximumEntities=”1″ MultiSelect=”false” AllowTypeIn=”false” Width=’500px’ />

The following code sample will get you the currently logged on user’s login from the PeopleEditor control:

ArrayList peEntities = myPeopleEditorControl.Entities;
PickerEntity pickEn = (PickerEntity)peEntities[0];
stringLogIn = pickEn.Key;

This comes handy when you want to create an SPUser context out of the entities kept in the PeopleEditor control. For example:

private SPUser GetUser(string logIn)

SPUser user = this.workflowProperties.Web.SiteUsers[logIn];
return user;

Don’t forget Required Field Validation on your people editor control if you want the code not to break on you.

Posted in Deployment, MOSS | Tagged: , | Leave a Comment »

Parsing the PeoplePicker and adding Users to a SP List

Posted by PANVEGA on January 3, 2008

That should do it. You should be able to save the entries from the PeoplePicker Control (PeopleEditor) to a list.

  1. Create a new Custom List named Demo. Within List Settings, create a column of type Person or Group named Employees
  2. In this particular example, I’ll be building a custom application page with a single PeopleEditor control and a submit button. Create a new page, called Demo.aspx and store it in the layouts directory.
  3. Since the people editor control is located within the Microsoft.SharePoint.WebControls namespace, you’ll have to register the tag prefix at the top of your page:
    <%@ Register TagPrefix=”wssawc” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>

  4. Insert the control on the page. If you look at my Demo.aspx page, I’ve put my control within a table tag, but you can format this however you’d like:
    <wssawc:PeopleEditor AllowEmpty=”false” Width=”300px” id=”peEmployees” runat=”server” SelectionSet=”User” />

    AllowEmtpy – let’s you specify if blank values are permitted for this control
    SelectionSet – can be User or SecGroup or SPGroup or all three: User, SecGroup, SPGroup
    MultiSelect – set to true or false, false if you don’t want the user to be able to select more than one


One thing I found was that in order for this control to successfully save a user, that user has to exist within the site collection. If they don’t exist, the web.SiteUsers call will fail with an exception ‘user cannot be found’.

SPWeb web = SPContext.Current.Web;

// get the entries submitted into the people editor and store them in a string

string employees= peEmployees.CommaSeparatedAccounts;

// commaseparatedaccounts returns entries that are comma separated. we want to split those up

char[] splitter = { ’,’ };

string[] splitPPData = employees.Split(splitter);

// this collection will store the user values from the people editor for storage into the list

SPFieldUserValueCollection values = new SPFieldUserValueCollection();

// for each item in our array, create a new sp user object given the loginname and add to our collection

for (int i = 0; i < splitPPData.Length; i++)


string loginName = splitPPData[i];

if (!string.IsNullOrEmpty(loginName))


SPUser user = web.SiteUsers[loginName];

SPFieldUserValue fuv = new SPFieldUserValue(web, user.ID, user.LoginName);




// set the Person or Group column

SPListItemCollection listItems = web.Lists[“Demo”].Items;

SPListItem employee = listItems.Add();

employee[Employees] = values;


Posted in MOSS | Tagged: , | 4 Comments »

Developing Custom Field Types

Posted by PANVEGA on February 18, 2007

In this post i am going to introduce how to develope a custom field type in 6 steps with the Sharepoint People Picker. Search the name you want, push the button in order to resolve the user enitities in the code behind class. Finnaly return the parsed values to a simple multiline text box. You can also create a datagrid or just a table to format the values.

First of all we are going to create the visual user interface. As the custom field will be deployed as an feature assembly, it is a good idea to create a class library project in Visual Studio 2005 or Visual Studio 2008. Prepare also the folder structure that is required for a feature. Read the rest of this entry »

Posted in ASP.NET, Deployment, DotNet, JavaScript, UserControls, WebParts | Tagged: , , , , , , | Leave a Comment »