Beispiel #1
0
        public static void GettingUserProfileProperties()
        {
            var clientContext = new ClientContext("http://svg-ronald:8080");
            var peopleManager = new Microsoft.SharePoint.Client.UserProfiles.PeopleManager(clientContext);
            var accountName   = "spdev\\administrator";

//            string[] prfProps = new string[] { "DisplayName", "Title" };
            //string[] prfProps = new string[] { "Manager", "FirstName" };


            //var usrPrfProps = new Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser(clientContext, accountName, prfProps);
            var profilePropertyValues = peopleManager.GetPropertiesFor(accountName);

            //var profilePropertyValues = peopleManager.GetMyProperties();

            clientContext.Load(profilePropertyValues);
            clientContext.ExecuteQuery();

            // Iterate through the property values.
            foreach (var property in profilePropertyValues.UserProfileProperties)
            {
                Console.Write(property.Key + ": " + property.Value + "\n");
            }
            Console.ReadKey(false);
        }
Beispiel #2
0
        public static void GettingSomeUserProfileProperties()
        {
            const string serverUrl  = "http://svg-ronald";
            const string targetUser = "******";

            // Connect to the client context.
            ClientContext clientContext = new ClientContext(serverUrl);

            // Get the PeopleManager object.
            Microsoft.SharePoint.Client.UserProfiles.PeopleManager peopleManager = new Microsoft.SharePoint.Client.UserProfiles.PeopleManager(clientContext);



            // Retrieve specific properties by using the GetUserProfilePropertiesFor method.
            // The returned collection contains only property values.
            string[] profilePropertyNames = new string[] { "PreferredName", "DisplayName23", "Department", "Title", "AboutMe" };
            Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser profilePropertiesForUser = new Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser(
                clientContext, targetUser, profilePropertyNames);
            IEnumerable <string> profilePropertyValues = peopleManager.GetUserProfilePropertiesFor(profilePropertiesForUser);

            // Load the request and run it on the server.
            clientContext.Load(profilePropertiesForUser);
            clientContext.ExecuteQuery();

            // Iterate through the property values.
            foreach (var value in profilePropertyValues)
            {
                Console.Write(value + "\n");
            }
            Console.ReadKey(false);
        }
        public static void GettingSomeUserProfileProperties()
        {
            const string serverUrl = "http://svg-ronald";
            const string targetUser = "******";

            // Connect to the client context.
            ClientContext clientContext = new ClientContext(serverUrl);

            // Get the PeopleManager object.
            Microsoft.SharePoint.Client.UserProfiles.PeopleManager peopleManager = new Microsoft.SharePoint.Client.UserProfiles.PeopleManager(clientContext);

            // Retrieve specific properties by using the GetUserProfilePropertiesFor method.
            // The returned collection contains only property values.
            string[] profilePropertyNames = new string[] { "PreferredName", "DisplayName23", "Department", "Title", "AboutMe" };
            Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser profilePropertiesForUser = new Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser(
                clientContext, targetUser, profilePropertyNames);
            IEnumerable<string> profilePropertyValues = peopleManager.GetUserProfilePropertiesFor(profilePropertiesForUser);

            // Load the request and run it on the server.
            clientContext.Load(profilePropertiesForUser);
            clientContext.ExecuteQuery();

            // Iterate through the property values.
            foreach (var value in profilePropertyValues)
            {
                Console.Write(value + "\n");
            }
            Console.ReadKey(false);
        }
        public static void ChangePicture(string userAccount)
        {
            var clientContext = new ClientContext("http://svg-ronald:8080/");

            //var peopleManager = new PeopleManager();

            var peopleManager = new Microsoft.SharePoint.Client.UserProfiles.PeopleManager(clientContext);
            var personProperties = peopleManager.GetPropertiesFor(userAccount);

            clientContext.Load(personProperties);

            var sr = new System.IO.FileStream("C:/Users/Administrator/Desktop/Temp/SharePoint-2013-logo.png",FileMode.Open);
            peopleManager.SetMyProfilePicture(sr);

            clientContext.Load(peopleManager);
            clientContext.ExecuteQuery();

            //var up = upm.GetUserProfile(userAccount);
            //up.Commit();
        }
Beispiel #5
0
        public static void ChangePicture(string userAccount)
        {
            var clientContext = new ClientContext("http://svg-ronald:8080/");

            //var peopleManager = new PeopleManager();

            var peopleManager    = new Microsoft.SharePoint.Client.UserProfiles.PeopleManager(clientContext);
            var personProperties = peopleManager.GetPropertiesFor(userAccount);

            clientContext.Load(personProperties);

            var sr = new System.IO.FileStream("C:/Users/Administrator/Desktop/Temp/SharePoint-2013-logo.png", FileMode.Open);

            peopleManager.SetMyProfilePicture(sr);

            clientContext.Load(peopleManager);
            clientContext.ExecuteQuery();

            //var up = upm.GetUserProfile(userAccount);
            //up.Commit();
        }
        public static void GettingUserProfileProperties()
        {
            var clientContext = new ClientContext("http://svg-ronald:8080");
            var peopleManager = new Microsoft.SharePoint.Client.UserProfiles.PeopleManager(clientContext);
            var accountName = "spdev\\administrator";

            //            string[] prfProps = new string[] { "DisplayName", "Title" };
            //string[] prfProps = new string[] { "Manager", "FirstName" };

            //var usrPrfProps = new Microsoft.SharePoint.Client.UserProfiles.UserProfilePropertiesForUser(clientContext, accountName, prfProps);
            var profilePropertyValues = peopleManager.GetPropertiesFor(accountName);
            //var profilePropertyValues = peopleManager.GetMyProperties();

            clientContext.Load(profilePropertyValues);
            clientContext.ExecuteQuery();

            // Iterate through the property values.
            foreach (var property in profilePropertyValues.UserProfileProperties)
            {
                Console.Write(property.Key + ": " + property.Value + "\n");
            }
            Console.ReadKey(false);
        }