I'm trying to initialize a connection between a .NET Core application and an xConnect installation.
I ran in to the following error:

An unhandled exception of type 'Sitecore.XConnect.XdbCollectionUnavailableException' occurred in mscorlib.dll The HTTP response was not successful: Unauthorized

Here is the stack trace:

at Sitecore.XConnect.Client.WebApi.ConfigurationWebApiClient.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Sitecore.XConnect.Client.XConnectClientConfiguration.d__32.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at CashRegisterApplication.Controllers.RegisterController.d__7.MoveNext()

End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at CashRegisterApplication.Controllers.RegisterController.d__4.MoveNext()

I've been looking for what is causing this error for a while now but i can't find any leads, has anyone seen this before or does anyone have tips where i can start looking?

EDIT:
I decided not to include this because i have no clue if it has anything to do with it but on second thought it could ring a bell for someone so here it goes:
The Collection.ShardMapManager database was created without a user, i added this user myself. I think it might have something to do with that. This post showed me there was no account configured for that database:

https://www.kasaku.co.uk/2017/11/05/sitecore-xconnect-shard-map-must-be-configured/

up vote 7 down vote accepted

UPDATE: Added mark's solution to help those looking for answers.

I can think of a few possible reasons you are getting an unauthorized issue:

  1. Your thumbprint or certificate is not properly installed so you are being blocked from connecting to xConnect
  2. Your application does not have access to the certificate (e.g. IIS user does not have permission)
  3. You did not execute the script in the installation guide Post-installation steps.

In the 9.0 Initial release installation guide, the following script needs to be executed. Remember to update user name and password to the appropriate ones for your system.

:SETVAR DatabasePrefix xp1
:SETVAR UserName collectionuser
:SETVAR Password Test12345
:SETVAR ShardMapManagerDatabaseNameSuffix _Xdb.Collection.ShardMapManager
:SETVAR Shard0DatabaseNameSuffix _Xdb.Collection.Shard0
:SETVAR Shard1DatabaseNameSuffix _Xdb.Collection.Shard1
GO
IF(SUSER_ID('$(UserName)') IS NULL)
BEGIN
 CREATE LOGIN [$(UserName)] WITH PASSWORD = '$(Password)';
END;
GO
USE [$(DatabasePrefix)$(ShardMapManagerDatabaseNameSuffix)]
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'$(UserName)')
BEGIN
 CREATE USER [$(UserName)] FOR LOGIN [$(UserName)]
 GRANT SELECT ON SCHEMA :: __ShardManagement TO [$(UserName)]
 GRANT EXECUTE ON SCHEMA :: __ShardManagement TO [$(UserName)]
END;
GO
USE [$(DatabasePrefix)$(Shard0DatabaseNameSuffix)]
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'$(UserName)')
BEGIN
 CREATE USER [$(UserName)] FOR LOGIN [$(UserName)]
 EXEC [xdb_collection].[GrantLeastPrivilege] @UserName = '$(UserName)'
END;
GO
USE [$(DatabasePrefix)$(Shard1DatabaseNameSuffix)]
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'$(UserName)')
BEGIN
 CREATE USER [$(UserName)] FOR LOGIN [$(UserName)]
 EXEC [xdb_collection].[GrantLeastPrivilege] @UserName = '$(UserName)'
END;
GO
  • I've removed the user i made myself and ran the script, this sadly did not fix my problem. What would be the best way to check if my thumbprint is correct? I think i have it set up the way it is supposed to but it was my first time doing so, i might have overlooked something. – mark DE Jong Nov 20 '17 at 15:18

I've encountered the SAME EXACT PROBLEM on my local machine. Had to scratch my head for 2 days, had to also ask help from a colleague to also help; troubleshoot it together - 2 brains are better than 1 - to just simply fix this. A bit troublesome.

First of all, follow what Jay S recommended and that will save a lot of your troubleshooting time, won't repeat it here.

After that, try this - if it didn't make sense, you'll never know.

IN MICROSOFT MANAGEMENT CONSOLE:

  • Remove unused SC certificates from your 'current user' certificate stores. Maybe for some reason, you have it there.
  • Type 'mmc' and open your Certificate Store for 'Local Computer'. Right-click your Sitecore certificate > All Tasks > Manage Private Keys. Grant full control to both NETWORK SERVICE and IIS_IUSRS. Do it for both xp0.xconnect and xp0.xconnect_client certificates.

enter image description here

This PowerShell command will identify non-self-signed certificates:

Get-Childitem cert:\LocalMachine\root -Recurse | 
    Where-Object {$_.Issuer -ne $_.Subject}

Move these non-self-signed certificates into the Intermediate Certification Authorities (i.e. CA) store

Get-Childitem cert:\LocalMachine\root -Recurse | 
    Where-Object {$_.Issuer -ne $_.Subject} | 
    Move-Item -Destination Cert:\LocalMachine\CA

IN IIS:

  • From your xp0.xconnect website, open your bindings and double-check the SSL certificate as it has to be valid. enter image description here
  • From the Application Pools, change the identity to NETWORK SERVICE enter image description here
  • Do IISRESET and clear your Sitecore Logs

YOU SHOULD ABLE TO SEE THIS IF EVERYTHING GOES INTO PLAN FROM YOUR SITECORE LAUNCHPAD: enter image description here

And when you access the https://xp01.xconnect, it should give you this kind of result. enter image description here

[UPDATED]

  • Forgot to mention, try to restart your laptop too.
  • Grant permission to your logged in user to xp0.xconnect as well.

Like Jay said:

"Your thumbprint or certificate is not properly installed so you are being blocked from connecting to xConnect."

I had a very though time finding out what the problem might have been. It turned out my IIS user did not have permission to see the Certificate. Once i gave my logged in user rights to see the Certificate i could establish a connection.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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