none
Utility.ResolvePrincipal in CSOM is returning Null values for a specific User RRS feed

  • Question

  • While trying to fetch the User Profile properties using the CSOM OM , Utility.ResolvePrincipal method in Sharepoint Online , Server is returning null values. 

    This issue is happening only with a particular user and it works fine for other users in AD.

    Thursday, February 2, 2017 5:26 PM

All replies

  • Hi

    did you use a full username to resolve the user? like domain\username


    顺其自然地勇往直前!—Justin Liu

    Friday, February 3, 2017 2:53 AM
  • Hi Nethi,

    Please check what the particular user is different.

    If you want to retrieve user profile properties, we can use PeopleManager to achieve it.

    The following code for your reference:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint.Client;
    using Microsoft.SharePoint.Client.UserProfiles;
    
    namespace UserProfilesCSOM
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                // Replace the following placeholder values with the target SharePoint site and
                // target user.
                const string serverUrl = "http://serverName/";  
                const string targetUser = "domainName\\userName";  
    
                // Connect to the client context.
                ClientContext clientContext = new ClientContext(serverUrl);
    
                // Get the PeopleManager object and then get the target user's properties.
                PeopleManager peopleManager = new PeopleManager(clientContext);
                PersonProperties personProperties = peopleManager.GetPropertiesFor(targetUser);
    
                // Load the request and run it on the server.
                // This example requests only the AccountName and UserProfileProperties
                // properties of the personProperties object.
                clientContext.Load(personProperties, p => p.AccountName, p => p.UserProfileProperties);
                clientContext.ExecuteQuery();
    
                foreach (var property in personProperties.UserProfileProperties)
                {
                    Console.WriteLine(string.Format("{0}: {1}", 
                        property.Key.ToString(), property.Value.ToString()));
                }
                Console.ReadKey(false);
    
                // TODO: Add error handling and input validation.
            }
        }
    }
    

    https://msdn.microsoft.com/en-us/library/office/jj163182.aspx

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, February 3, 2017 7:23 AM
    Moderator
  • We are passing the user's email ID like for example :  cathy.hutchinson@softchoice

    the code is written long back and works fine for all the users the application is used by except for Cathy.. 

    Friday, February 3, 2017 7:37 PM
  • the code is written long back and works fine for all the users of the application except for one user.

    I cannot change the logic used currently as it is already running in Production. I have Compare all the properties of the user in Sharepoint Admin center and also in Delve. Everything looks normal.



    Friday, February 3, 2017 7:42 PM
  • Please check if the UPS works well.

    顺其自然地勇往直前!—Justin Liu

    Monday, February 6, 2017 12:17 AM
  • Hi Nethi,

    Did you check this special user using my code above?

    Or check whether this user disable in AD or not.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, February 13, 2017 8:24 AM
    Moderator