About lavssun



View all posts by lavssun

How to set Profile Picture in Office 365 SharePoint 2013 site using CSOM

Home | SharePoint 2013 | How to set Profile Picture in Office 365 SharePoint 2013 site using CSOM

Step1

Create a console application in Visual Studio 2013.

Step2

Import the following namespaces

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.UserProfiles;

using System.Net;
using System.Security;
using System.Globalization; 

Step3

Add the following references

Step4

            Uri oUri = new Uri("https://yoursite.sharepoint.com");

            Office365ClaimsHelper claimsHelper = new Office365ClaimsHelper(oUri, "youruserid@yoursite.onmicrosoft.com", "password");
            using (ClientContext oClientContext = new ClientContext(oUri))
            {
                oClientContext.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
                PeopleManager oPeopleManager = new PeopleManager(oClientContext);
                
                Stream oStream = new FileStream(@"C:MyPhotoSundar.jpg", FileMode.Open);
                oPeopleManager.SetMyProfilePicture(oStream);
                oClientContext.ExecuteQuery();
                Console.Write("Profile picture is set");



                Console.ReadLine();
            }

How to read UserProfile property from Office 365 SharePoint 2013 site using CSOM

Home | SharePoint 2013 | How to read UserProfile property from Office 365 SharePoint 2013 site using CSOM

Step#1

Create a console application in Visual Studio 2013

Step#2

Import the following namespaces

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;

using System.Net;
using System.Security;
using System.Globalization;

Step#3

Add references to the following .dll

references

Step#3
 static void Main(string[] args)
        
        {
            ReadUserProfile();
            
           
        }

        public static void ReadUserProfile()
        {
            Uri oUri = new Uri("https://yoursite.sharepoint.com");

            Office365ClaimsHelper claimsHelper = new Office365ClaimsHelper(oUri, "youruserid@yoursite.onmicrosoft.com", "password");
            using (ClientContext oClientContext = new ClientContext(oUri))
                        {
                            oClientContext.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
                PeopleManager oPeopleManager = new PeopleManager(oClientContext);
                PersonProperties oPersonProperties = oPeopleManager.GetPropertiesFor("i:0#.f|membership|youruserid@yoursite.onmicrosoft.com");
                
                oClientContext.Load(oPersonProperties, p => p.AccountName, p => p.UserProfileProperties);
                oClientContext.ExecuteQuery();

                Console.WriteLine(oPersonProperties.UserProfileProperties.Count.ToString());
                
                foreach (var oProperty in oPersonProperties.UserProfileProperties)
                {
                    Console.WriteLine(string.Format("{0}: {1}",
                        oProperty.Key.ToString(), oProperty.Value.ToString()));
                    
                }
                Console.ReadLine();

            }

CSOM userprofile

The account parameter to be passed for the method oPeopleManager.GetPropertiesFor is not straight-forward. For office 365 SharePoint accounts, the parameter has to be passed in this format "i:0#.f|membership|youruserid@yoursite.onmicrosoft.com". Replace the youruserid accordingly.

The complete source code for this article is available in this location

 Subscribe to my blog

Visual Studio 2013 Community Launch @ Chennai–Dec 21, 2013

Home | MVP | Visual Studio 2013 Community Launch @ Chennai–Dec 21, 2013

Date/Time:
Saturday, December 21, 2013 from 9:30 AM to 1:00 PM (PST)

Location:
Chennai

471, 2nd floor, Prestige Polygon, Anna Salai
Rathna Nagar, Teynampet
Chennai, 600018
India

Agenda & Schedule

No Agenda Schedule
1 Registration 9:30 – 10:00 AM
2 Visual Studio Studio 2013 IDE Changes and what’s new in .NET 4.5.1 10:00 AM – 11:00 AM
3 Tea Break 11:00 AM – 11:15 AM
4 Web Development in Visual Studio 2013 11:15 AM – 12:15 PM
5 Build HTML 5 based LOB Apps with Light Switch 12:15 PM – 1:00 PM
6 Q&A 1:00 AM – 1:15 AM

 Subscribe to my blog

Useful resources on SharePoint 2013 Capacity Planning

Home | SharePoint 2013 | Useful resources on SharePoint 2013 Capacity Planning

I’ve collated a list of resources that comes handy when we do Capacity Planning and Sizing for SharePoint Server 2013. The list of resources are below :-

1.Hardware and software requirements for SharePoint 2013
http://technet.microsoft.com/en-us/library/cc262485.aspx

2. Enterprise scale farms for SharePoint Server 2013
http://www.microsoft.com/en-us/download/details.aspx?id=35569

3. Streamlined topologies for SharePoint Server 2013
http://www.microsoft.com/en-us/download/details.aspx?id=37000

4. Traditional topologies for SharePoint Server 2013
http://www.microsoft.com/en-us/download/details.aspx?id=30377

5.Plan and use the Distributed Cache Service in SharePoint Server 2013
http://www.microsoft.com/en-us/download/details.aspx?id=35557

6.Plan for feeds and the Distributed Cache Service in SharePoint Server 2013
http://technet.microsoft.com/en-in/library/jj219572.aspx

7.Enterprise Search architectures for SharePoint Server 2013
http://www.microsoft.com/en-us/download/details.aspx?id=30383

8.Internet sites search architectures for SharePoint Server 2013
http://www.microsoft.com/en-us/download/details.aspx?id=30464

9.Scale search for performance and availability in SharePoint Server 2013
http://technet.microsoft.com/en-us/library/jj219628.aspx

10.Capacity Planning, Sizing and High Availability for Search in SPC172
http://social.technet.microsoft.com/wiki/contents/articles/16002.sharepoint-2013-capacity-planning-sizing-and-high-availability-for-search-in-spc172.aspx

11.Configuring a highly available workflow in workflow manager
http://technet.microsoft.com/en-us/library/jj193534

12.Use best practice for configurations for the SharePoint 2013 virtual machines and Hyper-V environment
http://technet.microsoft.com/en-us/library/ff621103.aspx

13.Plan Office Web Apps Server
http://technet.microsoft.com/en-us/library/jj219435.aspx

14.Estimate performance and capacity requirements for enterprise intranet collaboration environments (SharePoint Server 2013)
http://technet.microsoft.com/en-in/library/ff758657.aspx

15.Estimate capacity and performance for Web Content Management (SharePoint Server 2013)
http://technet.microsoft.com/en-us/library/d819b0d0-aa83-4e40-82d8-7a32195cc669(v=office.15).aspx

16.Estimate capacity and performance for Managed Metadata Service
http://technet.microsoft.com/en-in/library/gg681889.aspx

17.Estimate capacity and performance for video content management in SharePoint Server 2013
http://technet.microsoft.com/en-us/library/dn169054.aspx

18.Estimate capacity and performance for compliance and eDiscovery for SharePoint Server 2013
http://technet.microsoft.com/en-us/library/dn169053.aspx

 Subscribe to my blog

Microsoft Community Day–Nov 9

Home | MVP | Microsoft Community Day–Nov 9

Tomorrow, Nov 9 is the Microsoft Community Day, there are whole lot of community activities planned around latest Microsoft technologies. 

The following webcasts are scheduled.

Working with Windows Azure IaaS

2:00PM IST

Register

What’s new in CRM 2013

3:00PM IST

Register

ONE ASP.NET

4:00PM IST

Register

Developing Near Field Communication in Windows Phone 8

5:00PM IST

Register

Windows 8 and Hyper-V

6:00PM IST

Register

Exchange Server 2013: Modern Public Folders

8:00PM IST

Register

Working with SharePoint 2013

9:00PM IST

Register

The following chat sessions are also scheduled

8103_image30_thumb_37F6FF58

If you are interested, please register here  http://blogs.technet.com/b/southasiamvp/archive/2013/11/04/community-day-activities.aspx

 Subscribe to my blog

Retrieve Person or Group field using SharePoint 2013 Client Object Model

Home | SharePoint Development | Retrieve Person or Group field using SharePoint 2013 Client Object Model

I’m involved in troubleshooting a crazy people picker field issue in SharePoint 2013, which necessitates me to programmatically query the Person or Group field of SharePoint list using Client Object model. I was trying to figure out the exact syntax that can be used to grab the Person or Group field using FieldUserValue objects. Here is the complete code below :-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using System.Net;

namespace ReadApproverNameField
{
    public class Program
    {
        static void Main(string[] args)
        {
            GetApproverDetails();
            Console.ReadLine();

        }

        public static void GetApproverDetails()
        {
            ClientContext clientContext = new ClientContext(http://servername/sites/sitecollectionname);
            
            NetworkCredential oNetworkCredential = new NetworkCredential();
            oNetworkCredential.Domain = @"Domain Name";
            oNetworkCredential.UserName = @"User Id";
            oNetworkCredential.Password = @"Password";
            clientContext.Credentials = oNetworkCredential;

            List list = clientContext.Web.Lists.GetByTitle("Name of the list");

            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View/>";
            ListItemCollection listItems = list.GetItems(camlQuery);
            clientContext.Load(list); 
            clientContext.Load(listItems);
            clientContext.ExecuteQuery();


            foreach (ListItem oListItem in listItems)
            {
                
                FieldUserValue name = oListItem.FieldValues["ApproverName"] as FieldUserValue;
                string person = name.LookupValue;                
                Console.WriteLine(oListItem.Id + "     " + oListItem["Title"].ToString() + "     " + person);


            }
        }
    }
}
Basically we cannot create a new instance of FieldUserValue object, it needs to be casted from the current item’s field using ‘as FieldValue’ syntax
and then the LookupValue need to be invoked to fetch the value. If we run the above code, we’ll get the output below.
pic1

 Subscribe to my blog

Import MS Project 2010 plan to Project Server

Home | General | Import MS Project 2010 plan to Project Server

This article will cover the steps required to import the Project Plan created in MS Project 2010 to the Project Server (Project Web Access). This assumes that you’ve already established a connectivity to the Project Server through File –> Info –> Manage Accounts –> Add

pic1

Now let’s add an option in the Ribbon Control to enable upload the project plan to Project Server

File –> Options –> Customize Ribon

Under Main Tabs –> Project –> Create a a new group pressing ‘New Group’ button

On the left side –> Choose commands from –> Select ‘Import Project to Enterprise’

pic2

Now you’ll get to see an option called ‘Import Project to Enterprise’ under Projects in Ribbon.

 Subscribe to my blog

Connecting MS Project 2010 to Project Web App

Home | Office Development | Connecting MS Project 2010 to Project Web App

I was trying to connect MS Project 2010 to a Project Web App (MS Project Server), got this error “.

pic1

The root cause of the issue was that, the MS Project 2010 was not able to connect to Project Web App using the logged on user’s credential.

I had to make a change to the following browser settings to get this working.

IE –> Tools –> Internet Options –> Security –> Intranet (in my case PWA site is hosted in intranet zone)

Custom Level –> User Authentication –> Logon –> Prompt for user name and password

pic2

 Subscribe to my blog

You can’t remotely debug events Windows Azure Service Bus connection string is missing

Home | SharePoint 2013 App | You can’t remotely debug events Windows Azure Service Bus connection string is missing

I was trying to debug a SharePoint 2013 remote event receiver running against a SharePoint Hosted App in Visual Studio 2012. I got the following error.

pic1

I learnt that I need to create a Windows Azure Service Bus and configure the end point of Azure Service Bus in the Visual Studio project property.

Create a new service bus object in Azure Management Portal

pic3

Go to project property in Visual Studio 2012 –> SharePoint Tab –> Enable Remote Debugging by providing the endpoint of the Azure Service Bus

pic4

Now we’re able to debug the remote event receiver in Visual Studio 2012.

pic2

 Subscribe to my blog

Microsoft MVP Lunch Hour Session on Sep 18

Home | General | Microsoft MVP Lunch Hour Session on Sep 18

I’m conducting a session for the South Asia Microsoft MVP Lunch Hour series  on Microsoft events online platform (msevents.microsoft.com).

The topic is ‘SharePoint 2013 Remote Event Receivers” and it will be a Level 300 session. The event date is 18’th September 2013.

If you are interested, please register it in the below link
https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032561518&Culture=en-IN&community=0

 Subscribe to my blog