Categories
Sitecore

Troubleshooting Sitecore 9 Login

When working with Sitecore 9, you might encounter a frustrating login error with the message “String or binary data would be truncated.” This issue occurs when Sitecore generates a login ticket that exceeds the database column size limitations.

An Error Occurred, String or binary data would be truncated

Understanding the Problem

The root cause is that Sitecore sometimes creates authentication tickets that are too large for the database field. This typically happens because the URL (or portions of it) gets incorporated into the ticket, causing it to exceed the allocated database space.

If you check your logs, you’ll likely see an error stack trace similar to this:

Nested Exception
Exception: System.Data.DataException
Message: Error executing SQL command: INSERT INTO [Properties] ( [Key], [Value] ) VALUES ( @name, @value )
Nested Exception
Exception: System.Data.SqlClient.SqlException
Message: String or binary data would be truncated.
The statement has been terminated.
Source: .Net SqlClient Data Provider

You can also check the tickets in the DB

Select * FROM [bekrw_prd_Core].[dbo].[Properties]
  where [Key] like 'CORE_SC_TICKET_%'
  and [Value] like '%username-in-sitecore%'

The Solution

Fortunately, there’s a straightforward fix. You need to remove the problematic ticket from the core database, which will force Sitecore to generate a new ticket during your next login attempt.

Execute this SQL query against your core database:

Delete FROM [bekrw_prd_Core].[dbo].[Properties]
  where [Key] like 'CORE_SC_TICKET_%'
  and [Value] like '%username-in-sitecore%'

Read More