Legacy Knowledge Base
Published Jun. 30, 2025

Error while Importing LDAP data: SQLServerException: String or binary data would be truncated

Written By

Neil Cuzon

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.
Issue

  • LDAP import fails due to an error stating that the user could not be updated due to a DataException,  which is in turn caused by a SQLServerException, stating that String or binary data would be truncated.
  • Please refer below for an example of the error:

    ERROR [liferay/scheduled_user_ldap_import-1][LDAPUserImporterImpl:817] Unable to import user CN=Fake Name,OU=STU,OU=UserAccounts,OU=Tier2,OU=FakeCompany: null:null:{samaccountname=sAMAccountName: Fake.Name}

    org.springframework.dao.DataIntegrityViolationException: could not update: [com.liferay.portal.model.impl.UserImpl#9999999]; SQL [update User_ set mvccVersion=?, modifiedDate=?, jobTitle=? where userId=? and mvccVersion=?]; nested exception is org.hibernate.exception.DataException: could not update: [com.liferay.portal.model.impl.UserImpl#9999999]
    (...)
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.

Environment

  • DXP 7.0

Resolution

  • The issue occurs because a column in the LDAP data being imported contains more characters than is allowed for that matching column in the database.  
  • To resolve this issue, you could create and use Custom Fields or,  you can reduce the character count of the offending column. 
  • To reduce the character count, you can review the data of the CN named in the error and check the character limits for all the columns in the database, and cross-reference it to the character count of the contents of the LDAP columns. 
  • Please note that we discourage changing the character limits in your database, as this could cause upgrade issues further down the line. 




Did this article resolve your issue ?

Legacy Knowledge Base