We created a custom user profile property.

We want to read it's value via CSOM (or PnP, doesn't matter).

We fail.

Our property is not returned in the list of user profile properties. Other properties are returned. Our custom property is not.

This property is configured like this:

  • multi-valued
  • length: 3600
  • Optional
  • Visible to "Only me"
  • Not Replicable
  • Editable by user
  • Not visible anywhere (used in SPFx solution)

This other post reports a similar effect. This post from 2013 claims that properties with visibility "Only me" cannot be retrieved via CSOM.

I want this to clear this up for SharePoint Online:

Is it possible to read each and every user profile property via CSOM? If not: What could be the reason for a property not being returned? I did not find any documentation so far.

  • 1
    what's the security context that's executing the CSOM? The same user, or a different user? – Derek Gusoff Oct 18 '18 at 12:45
  • @DerekGusoff the SharePoint admin who wants to set the property for > 1000 users – Heinrich Ulbricht Oct 18 '18 at 16:15

Works for me. I can see "Only Me" properties on users and their values while logged in as a tenant admin using this.

$act = Get-PnPUserProfileProperty -Account 'user@tenant.onmicrosoft.com'

Get-PnPUserProfileProperty uses CSOM under the covers. So if it's not coming back for you, there's either an issue with your code, or with your security context.

| improve this answer | |

Using PowerShell you can read properties that have visibility set to only me .

For example you can try this ,

$propertyValue = $userprofile["ExampleProperty"].value

| improve this answer | |

As Get-PnPUserProfileProperty is also not working for me for the private properties, "Only Me" properties, I am sharing another way to get "Only Me" properties by using the web service /_vti_bin/UserProfileService.asmx?wsdl. Below is a code sample

$adminUrl = "https://tenant-admin.sharepoint.com";
$accountName = "i:0#.f|membership|user@tenant.onmicrosoft.com"
$fieldInternalName = "CustomField"

$creds = Get-Credential -Message "Please specify the admin credentials"

$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName, $creds.Password)

$upService = New-WebServiceProxy -Uri ("$adminUrl/_vti_bin/UserProfileService.asmx?wsdl") -UseDefaultCredential False
$upService.Credentials = $credentials
$uri = New-Object System.Uri($adminUrl)
$container = New-Object System.Net.CookieContainer
$container.SetCookies($uri, $credentials.GetAuthenticationCookie($adminUrl))
$upService.CookieContainer = $container

$userData = $upService.GetUserProfileByName($accountName)
$userField= $upService.GetUserPropertyByAccountName("$accountName",$fieldInternalName).Values | select -ExpandProperty Value

Write-Output "------ User Fields"
Write-Output $userData

Write-Output "------ User Field ($fieldInternalName)"
Write-Output $userField
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.