Unable to start User Profile Service Application – Starting

The User Profile Synchronization service for SharePoint 2010 or 2013 can fail to start for numerous reasons. This post is for when the User Profile Service Application(UPA) is stuck on Starting. This prevents anybody from creating connections or syncing users.


This will prevent the User Profile Service Application from functioning properly. ULS shows the topology.svc tossing this “The requested application could not be found” with EventID evr4.

We can try to start the by running the Provision method to get the service application Started.

$upa = Get-SPServiceApplication <GUID of Service Application>

$upa.Provision()

This did fail and in the ULS logs we found this entry.

05/26/2018 11:13:46.90    PowerShell_ISE.exe (0x4AF4)    0x48F4    SharePoint Portal Server    User Profiles    ojxm    High    SSP administration site owner is ‘i:0#.w|oldaccount\deleted’.    018afcc8-f800-0001-5e35-00e1678bd301

SSP administration is a blast from the past. The reference is back to 2007 but service applications replaced the SSP in SharePoint 2010. This entry is stating we’re looking for owner of the Central Admin. This value can be exposed by using PowerShell as well.

$site = Get-SPSite http://centralAdmin:1234

$site.Owner

 

Or the UI with Site Settings and Site Collection Administrators

Or the Change site collection administrators in Central Admin

 

Find that account there and replace it with a valid account then run the Provision() PowerShell.

 

 

SAML roles and SharePoint 2016/2013 with OAuth

Roles (security groups) with SAML/ADFS will not work with OAuth without some more configuration and patching. OAuth affects 2013 Workflows, Office Web Apps, Provider Hosted Apps, Cross Farm Publishing/Consuming scenarios, Hybrid, etc. There are a few steps and requirements that are needed for this to work. KB 3203164 has some great information on this topic on setting the GroupClaimType.

NOTE: SharePoint 2013 must at (or later) March 2016 CU (15.0.4805.1000). SharePoint 2016 introduces the GroupClaimType with the September 2017 (16.0.4588.1000, Feature Pack 2) but we suggest deploying January 2018 PU (16.0.4639.1001) due to the regression causing Windows Claims Oauth augmentation to fail.

User Profiles are Key

User profiles are utilized when augmenting the role claims. The groups and users must be imported and synced within the User Profile Service application.

Map your Identifier claim

Run this PowerShell script to find the identifier claim:

$tips = Get-SPTrustedIdentityTokenIssuer

foreach($tip in $tips)

{

$name = $tip.Name

$claims = $tip.ClaimTypeInformation

foreach($claim in $claims)

{

If($claim.IsIdentityClaim -eq $true)

{

Write-Host -ForegroundColor DarkGreen “The Identity Claim is listed below for $name“

$claim } }}

Example of the script results when Email was the Identifier claim:

In the User Profile Service Application à Manage User Properties, edit the properties of the Claim User Identifier.

SharePoint 2016’s Active Directory Import automatically maps Claim User Identifier to saMAccountName. We would need to change that to correct identifier property in Active Directory. Any change in mappings will require a full sync.

Adding a new mapping for the identifier claim:

Group Membership in User Profiles

There are two ways to get this information – SQL or PowerShell. The PowerShell one will show nested groups unlike the SQL query.

Run this against your Profile Database and modify the domain\username to fit the user profile that we are searching for. This information would be in the UPA when searching for a User Profile.

SQL – SharePoint 2016

Select upa.UserProfile_Full.NTName, upa.MemberGroup.DisplayName as ‘Group Name’, upa.MemberGroup.SourceReference

From upa.UserProfile_Full with(nolock) JOIN upa.UserMemberships on upa.userprofile_full.RecordID = upa.UserMemberships.RecordID

Join upa.MemberGroup on upa.Usermemberships.MemberGroupId = upa.Membergroup.ID

Where NTName = ‘domain\username’

SQL – SharePoint 2013

Select UserProfile_Full.NTName, MemberGroup.DisplayName as ‘Group Name’, MemberGroup.SourceReference

From UserProfile_Full with(nolock) JOIN UserMemberships on userprofile_full.RecordID = UserMemberships.RecordID

Join MemberGroup on Usermemberships.MemberGroupId = Membergroup.ID

Where NTName = ‘domain\username’

Bdoe has 5 group memberships in the UserProfile service application.


PowerShell

$site = Get-SPSite “http://adamsor-2013upa”

$userprofile = “i:05.t|adfs|user@contoso.com”

$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);

$pm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)

$up = $pm.GetUserProfile($userprofile)

[xml]$xml = ($up.Memberships.GetDataSet()).getxml()

$xml.SelectNodes(“//Title”)

Output:

GroupClaimType

This property shown when running Get-SPTrustedIdentityTokenIssuer

As KB 3203164 states, we only have two options, the Role or GroupSID for claims.

PowerShell:

#Create a variable containing the SPTrustedIdentityTokenIssuer object
$issuer = Get-SPTrustedIdentityTokenIssuer

#Set the GroupClaimType property to the Role claim type, do not run for GroupSID claim type
$issuer.GroupClaimType = [Microsoft.IdentityModel.Claims.ClaimTypes]::Role

#Set the GroupClaimType property to the GroupSID claim type, do not run for Role claim type
$issuer.GroupClaimType = [Microsoft.IdentityModel.Claims.ClaimTypes]::GroupSid

#Update the SPTrustedIdenityTokenIssuer object to apply the change
$issuer.Update()

There is another way….

Custom claim providers can be developed to augment claims. This can be used instead of completing the steps above. The link below will get you started on that path of development.

https://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-create-a-claims-provider-in-sharepoint

Migrate Users (Move-SPUser) when moving from Windows to SAML/FBA

When adding another authentication provider to a web application like ADFS(SAML) or FBA(LDAP), SharePoint sees these users and roles(groups) as entirely different users and groups than Windows counterparts. The backend Active Directory might be the same along with usernames and passwords but to SharePoint these are different users.

Different Users, Different Permissions

I’ve deployed ADFS to a web application. I have added both my ADFS and Windows accounts to the site collection. The UserInfo table shows as two different users.


One is a site collection administrator but the other one is not.

What’s the difference?

The users will experience different…

  • User Profiles
  • My Sites
  • Permissions(users will report random access denied)
  • Alerts
  • Personal Views

People picker will also show two different accounts. This will further confuse end users on which account is correct.


The Best Practice

Migrate the farm to utilize one type of authentication. Mixed authentication can be done but only for a subset of users. If you’re utilizing ADFS, I suggest checking out my previous post on how to migrate to ADFS from Windows claims.

If you’re wanting to keep Windows Authentication but need something like SAML for working away from the office, I would suggest checking out Web Application Proxy (WAP). This will not require SharePoint to migrate any of the users. The SAML authentication happens at WAP then translate the token to Kerberos for SharePoint.

Deleting User Profiles Using PowerShell

There are many reasons why we would want to use a PowerShell shell script to delete user profiles.

  1. We don’t want to use or trust the My Site Cleanup job.
  2. We have a batch of stub user profiles that need to be deleted.
  3. We just want to delete some user profiles for testing purposes.
  4. We don’t want to wait 30 days before the User Profile is deleted by the My Site Cleanup timer job(applies only to SharePoint 2016)

NOTE: Deleting user profiles with this script will delete just the user profile.  This will not delete their My Site or send out that notification like the My Site cleanup job. WARNING: This script will delete user profiles specified in the file. The only other means to recover the user profile is to restore the Profile DB from backup.

The List

There are a few ways that we can gather a list of user profiles. We can query the profile database, run GetNonImportedObjects, or we already have a list that we want to delete.

  1. Profile DB query – Select NtName from UserProfile_Full with(nolock) where bdeleted=1
  2. PowerShell:


$upa = Get-spserviceapplication | ?{$_.typename -match "profile"}
Set-SPProfileServiceApplication $upa -GetNonImportedObjects $true | out-file c:\temp\NonImportedProfiles.txt

We just want the list to be a text file with the a NTName on each line.

Parameters


We will just need to modify the top 3 lines to adjust it for our farm. The first is $siteurl. This should be URL that is consuming from the User Profile Service Application. The $file is the location and name of the input file we created above. The $log is for the location of the log file(Yes, there is logging with my PowerShell scripts). Just make sure the directory is created.

One gotcha is to make sure the account running this script has permissions to the User Profile service application. This can be accomplished in Central Admin with adding the account into Permissions with Full Control.

Link to the Script

SharePoint 2016 MIM and SAML/FBA User Profiles

There is not much out there about MIM and SharePoint 2016 with FBA or SAML user profiles.  Using Active Directory Import is still the same as it was in 2013.   Below we will be going through how to set this up for SAML(ADFS) and MIM.
This guide assumes the environment has been setup from these steps at https://technet.microsoft.com/en-us/library/mt637055(v=office.16).aspx

Why should we do this?

The account name for user profiles are important and what is used to get the profile. Windows Authentication user profiles are just “domain\username” for the account name. When SAML or FBA users invoke the user profiles, the profile service will search for the complete claim(example: “i:05.t|adfs30|User1”). If the user profile is not there, a stub profile will be created. This will give the user two profiles. The main one with SAML/FBA will NOT be sync’d since we would need configure MIM know the claim prefix.

 

1.       Open MIM client then Metaverse Designer.  Select “person” then “Add Attribute”.


New Attribute button.


Type in “SPS-ClaimID” for Attribute Name


Click OK

2. Open the ADMA then Configure Attribute Flow. Select user/person


 

a.       Map your Claim identifier for your SAML users to SPS-ClaimID.  The direction should be Import and Direct.


b.       Click “New”.


Find SPS-ClaimProviderType and SPS-ClaimProviderID in MetaVerse object type.  Below is PowerShell to find your SAML Identity Claim.

$tips = Get-SPTrustedIdentityTokenIssuer

foreach($tip in $tips)

{

$name = $tip.Name

$claims = $tip.ClaimTypeInformation


foreach($claim in $claims)

{


If($claim.IsIdentityClaim -eq $true)

{


Write-Host -ForegroundColor DarkGreen “The Identity Claim is listed below for $name“


$claim } }}

 


Select “Advanced” for “Mapping type” and “Import” for Direction.  Click New. 

The constant value SPS-ClaimProviderID will be the name of your SAML provider when you created it. 

SPS-ClaimProviderType will be “Trusted” if you’re using a Trusted provider.


3.       Open SharePoint MA(SPMA). Click on Select Attributes.  Check the box for SPS-ClaimID.

4.      Configure Attribute Flow. Select user/person.

a.       Map SPS-ClaimID to SPS-ClaimID.  The direction will be export and Direct.  Click new. 

I’m using UPN for my environment.  This will be the identifier claim which could be email or samaccountname(see above for PowerShell).


5.       Run a full sync