Accessing columns in the User Information List

I was recently asked how to programmatically retrieve custom fields from the User Information List via a Web service.

It turns out that the GetUserInfo web method does not return any custom fields that you might add to the User Information List (aka People & Groups).

Instead, just treat this as a regular SharePoint list and you can access the columns via the GetListItems web method from Lists.asmx.

static void Main(string[] args)
ListsService.Lists svcLists = new ListsService.Lists();
svcLists.Credentials = CredentialCache.DefaultCredentials;
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Document><Query /><ViewFields /><QueryOptions /></Document>");
XmlNode listQuery = doc.SelectSingleNode("//Query");
XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
Guid g = GetWebID("");
    System.Xml.XmlNode items = svcLists.GetListItems("User Information List",
string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions,                 g.ToString());

private static Guid GetWebID(string webPath)
SiteDataService.SiteData svcSiteData = new SiteDataService.SiteData();
svcSiteData.UseDefaultCredentials = true;
SiteDataService._sWebMetadata webMetaData;
SiteDataService._sWebWithTime[] arrWebWithTime;
SiteDataService._sListWithTime[] arrListWithTime;
SiteDataService._sFPUrl[] arrUrls;
string roles;
string[] roleUsers;
string[] roleGroups;
svcSiteData.Url = webPath + "/_vti_bin/sitedata.asmx";
uint i = svcSiteData.GetWeb(out webMetaData, out arrWebWithTime,
out arrListWithTime, out arrUrls, out roles, out roleUsers,
out roleGroups);
Guid g = new Guid(webMetaData.WebID);
return g;

Now if I add a column to the User Information List, that new column appears in the items list.

One other option is RSS. The User Information List has an RSS feed and you can configure it to include your custom columns. Of course, this only shows new records and is not useful for export or update.