Skip to main content

Read all the SharePoint User profile field using CSOM

The article shows CSOM and C# code to read all the user profile field. create a console application and copy the code below and replace the siteurl, user id and password with your sharepointURL , user id and password.

You need to add three dll to run this code:-
Microsoft.SharePoint.Client
Microsoft.SharePoint.Client.Runtime
Microsoft.SharePoint.Client.UserProfiles

Add this dll and run the code. Enjoy Coding.



using System;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.UserProfiles;
using System.Security;
namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            using (ClientContext clientContext = new ClientContext(Yoursiteurl))
            {
                string UName = "Your user name";
                string Upassword = "Password";

                SecureString SecurePassword = GetSecureString(Upassword);
                clientContext.Credentials = new SharePointOnlineCredentials(UName, SecurePassword);
                PeopleManager peopleManager = new PeopleManager(clientContext);
                PersonProperties personProperties = peopleManager.GetMyProperties();
                clientContext.Load(personProperties);
                clientContext.ExecuteQuery();
               foreach (var item in personProperties.UserProfileProperties)
                {
                      Console.WriteLine(item.Key);
                }
                   Console.ReadKey();
            }
        }
   private static SecureString GetSecureString(String Password)
        {
            SecureString oSecurePassword = new SecureString();

            foreach (Char c in Password.ToCharArray())
            {
                oSecurePassword.AppendChar(c);
            }
            return oSecurePassword;
        }
   }
}

Comments

Popular posts from this blog

SharePoint Designer workflow error : server side activities have been updated. you need to restart sharepoint designer to use the updated version of activities.

While working with SharePoint designer at the time of creating custom forms and workflows, on editing the workflow or creating new one, error occured and stated as :

"server side activities have been updated. you need to restart sharepoint designer to use the updated version of activities."

to resolve this error follow steps provided below.

Before moving on the steps mentioned below some time it's needed to clear the cache.

First clear the cache from locations mentioned below:
%APPDATA%\Microsoft\Web Server Extensions\Cache %APPDATA%\Microsoft\SharePoint Designer\ProxyAssemblyCache %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache %APPDATA%\Microsoft\SharePoint Designer
Steps to resolve this problem:
To resolve this issue you need to update the SharePoint designer and to do so you have to follow this
two steps :

1. Check whether the Microsoft SharePoint 2013 service pack 1 is installed or not in your system.If not Please download it and install from URL mentioned below : 
F…

The Google Doodle...

Everyday when we open browser is and type www.google.com and page is open, we see that Google logo is appearing very attractive and showing some message, question arise in our mind
1 what is this image?
2 who design it?

So, we will give you answer of all the question.......!
Every time when we hit google.com in any web browser and google search page is appeared with an attractive google logo and that attractive image is nothing but an Google Doodle.

What is this Google Doodle?
Doodles are the changes made with google logo to celebrate an special event, an special day or birth anniversary of artist, scientist. This is the google's way to tribute.
All started when the  first time when the stick figure drawn behind the second "o" of google in 1998, Burning Man Fastival.

Who Design Google Doodle?
Google Doodle is designed by the team of best illustrator call them doodlers with team of engineers.

Google user can also share idea for google doodle?
Hundreds of user everyday share…

Tez become Google Pay.

Tez become Google Pay, Google pay have all the functionalities which was exists in tez.
Google pay come with new exciting and user friendly features, which definitely impress the users, rewards and offers remains same like Tez.


Google pay offering some new exciting features, using it you can send money even if your contact is not on google pay.  Pay money using the Google pay now you can send money to those contact, who are not on Google play.Recharge your mobile using Google Pay.Pay near by, this is very impressive now you can send money to another google pay user without sharing private details like Bank account and contact number, same as handling cash.    Google Pay is available on the Google Play and App store. for more information you can visit "https://pay.google.com/intl/en_in/about/"