Web collaboration consultant, public speaker and Microsoft Press Author. @resing on twitter

User Profile Property and Property Mapping Troubleshooting

Working with a remote server today, I thought it would be helpful to see some information about the User Profile Properties without being able to see the server. Rather than ask the on site administrator for a bunch of screen shots, I decided to use PowerShell and the SharePoint API.

The User Profile Store and a Deprecated Method

The first sample code I came across used the deprecated method UserProfileConfigManager.GetProperties. Using this carry over from SharePoint 2007, you can still get details on the properties in SharePoint 2010, but it’s not guaranteed to be available in SharePoint vNext, so it’s best to move on to the new UserProfiles.ProfileSubtypeManager and the corresponding ProfileSubtypePropertyManager. It took more than a few minutes for me to walk through the MSDN docs on this, so I thought I’d share the short script with you. The following script will retrieve the properties of a SharePoint Server 2010 farm with User Profile Service Application configured to provide services for the site at the address http://portal.tomresing.local.

Sample Script 1

#ProfileSubtypeManager replaces GetProperties() for 2010
Add-Type -Path "c:program filescommon filesmicrosoft sharedweb server extensions14isapimicrosoft.office.server.dll"
$siteUrl = http://portal.tomresing.local
$site = Get-SPSite $siteUrl
$context = Get-SPServiceContext $site
$ProfileSubtypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($context)
$ProfileSubtypeManager.GetSubtypesForProfileType(1)[0].Properties
$site.Dispose()

Sample Script 1 Example Output

The output of the first script will be many sets of the list of property details like the details for the Property named Id below. The names and values in the set of details are easy to match to what you see in the User Profile Service Management page in Central Administration for User Profile Management.

ProfileName         : UserProfile
IsSection           : False
DisplayName         : Id
IsAlias             : False
AllowPolicyOverride : False
IsRequired          : True
IsUserEditable      : False
IsAdminEditable     : False
IsImported          : False
DefaultPrivacy      : Public
UserOverridePrivacy : False
PrivacyPolicy       : Mandatory
DisplayOrder        : 1
CoreProperty        : Microsoft.Office.Server.UserProfiles.CoreProperty
TypeProperty        : Microsoft.Office.Server.UserProfiles.ProfileTypeProperty
IsUpgrade           : False
IsUpgradePrivate    : False

The User Profile Property Mappings

You can use this second script to send to the screen all of the property mappings and their details from a site at the address http://portal.tomresing.local which a User Profile Connection named tomresing.local.

Sample Script 2

Add-Type -Path "c:program filescommon filesmicrosoft sharedweb server extensions14isapimicrosoft.office.server.dll"
$siteUrl = "http://portal.tomresing.local"
$site = Get-SPSite $siteUrl
$context = Get-SPServiceContext $site
$upConfigManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)
$connectionManager = $upConfigManager.ConnectionManager
$connection = $connectionManager["tomresing.local"]
$pmc = $connection.PropertyMapping
$pmc.GetEnumerator()
$site.Dispose()

Sample Script 2 Example Output

The output of the script will be one set of the property details for each mapping that exists in your connection. The following example shows the details for Active Directory Properties named wWWHomePage and sAMAccountName.

PropertyMapCollection          : Microsoft.Office.Server.UserProfiles.PropertyM
                                 apCollection
IsImport                       : True
IsExport                       : False
ProfileProperty                : Microsoft.Office.Server.UserProfiles.ProfileTy
                                 peProperty
DataSourcePropertyName         : wWWHomePage
OriginalDataSourcePropertyName : wWWHomePage
AssociationName                : 
Connection                     : Microsoft.Office.Server.UserProfiles.ActiveDir
                                 ectoryConnection

PropertyMapCollection          : Microsoft.Office.Server.UserProfiles.PropertyM
                                 apCollection
IsImport                       : True
IsExport                       : False
ProfileProperty                : Microsoft.Office.Server.UserProfiles.ProfileTy
                                 peProperty
DataSourcePropertyName         : sAMAccountName
OriginalDataSourcePropertyName : sAMAccountName
AssociationName                : 
Connection                     : Microsoft.Office.Server.UserProfiles.ActiveDir
                                 ectoryConnection

Conclusion

PowerShell makes it easy to view information about your User Profile Store and it’s mappings using the SharePoint SDK. Watch out for methods marked obsolete in the SDK, however. These methods should be avoided in new code because they may not be available in SharePoint vNext.

Note

If you’re doing this you may get an exception "No User Profile Application available to service the request. Contact your farm administrator." It’s a permissions issue you can fix in Manage Service Applications in Central Administration. MCM Instructor Steve Peshka explains on his blog.

3 Comments
  1. “The names and values in the set of details are easy to match to what you see in the User Profile Service Management page in Central Administration for User Profile Management.”. I’m having a difficult time mapping those values to what i see through central admin… for example: IsAdminEditable vs IsUserEditable, what is the difference? Also, how can i determine if it is Visible on on the profile page / edit details page? replicable?

    thanks for the help!

  2. I have tried the script 2 in my sharepoint. The script retrieve only 14 mappaed properties..but I have 26 mapped for Export properties in my sharepoint 2010.
    Thanks for any help
    Lorenzo

  3. Hi Lorenzo,
    Thanks for reading and commenting. Is it possible you have more than one profile subtype? http://blogs.perficient.com/microsoft/2011/06/creating-and-defining-profilesubtypes-programmatically/
    Tom

Leave a Reply