Since SharePoint 2010, Microsoft announced Client object model to developer community and it really help to extent SharePoint to many other platform.  SharePoint client object model (CSOM) allow you to manage data in SharePoint such as list data, user profile, ….

In SharePoint 2013, I’m very impressive with CSOM since it support for multiple plat for

  • .NET Framework redistributable assemblies
  • JavaScript library
  • REST/OData endpoints
  • Windows Phone assemblies
  • Silverlight redistributable assemblies

This artile show a code snippet for demo how to get user from a list data

        public static User GetUserFromAssignedToField() 
            string strUrl="http://" + Environment.MachineName; 
            // create site context 
            ClientContext ctx = new ClientContext(siteUrl); 
            // create web object 
            Web web = ctx.Web; 
            // get Tasks list 
            List list = ctx.Web.Lists.GetByTitle("MyList"); 
            // get list item using Id e.g. updating first item in the list 
            ListItem targetListItem = list.GetItemById(1); 
            // Load only the assigned to field from the list item 
                             item => item["AssignedTo"]); 
            // create and cast the FieldUserValue from the value 
            FieldUserValue[] fuv = (FieldUserValue[])targetListItem["AssignedTo"]; 
            User user = null; 
            for (int i = 0; i < fuv.Length; i++) 
                Console.WriteLine("Retrieved user Id is: {0}", fuv[i].LookupId); 
                Console.WriteLine("Retrieved login name is: {0}", fuv[i].LookupValue); 
                user = ctx.Web.EnsureUser(fuv[i].LookupValue); 
            return user; 

For more detail about CSOM: You can find at on MSDN

Hoang Nhut NGUYEN