Check if the people picker has a user or a group in sharepoint Programatically

A quick tip to check if the account in the people picker field for an item is a User or a SharePoint group using code.

Code -
SPweb web = SPContext.Current.Web;

SPFieldUserValue _pickerValue = new SPFieldUserValue(web, item["PeoplePickerName"].ToString());

bool isUser = SPUtility.IsLoginValid(site, pickerValue.User.LoginName);

if (isUser)
// Its a SharePoint User

// Its a SharePoint Group



Post a Comment


This is a personal weblog. The opinions expressed here represent my own and not those of my employer or anyone else. Should you have any questions or concerns please e-mail me at .

Copyright (c) 2010 @ All rights are reserved.Do Not Copy.

@ Learning