App Portal DataSync error: String or binary data would be truncated

App Portal DataSync error: String or binary data would be truncated

Summary

A SQL exception is generated when a specific piece of data is of a length beyond what the App Portal database can hold.

Symptoms

A SQL exception is generated when a specific piece of data is of a length beyond what the App Portal database can hold. To check whether there are users within SCCM with data beyond the width of the App Portal database, the following two queries can be run against ConfigMgr?s database:
select * from v_R_User
where
len(givenName0) > 255 OR
len(sn0) > 255 OR
len(Network_Operating_System0) > 255 OR
len(physicalDeliveryOfficeNam0) > 255 OR
len(l0) > 255 OR 
len(postalCode0) > 32 OR
len(department0) > 255 OR
len(title0) > 255 OR
len(User_Name0) > 255 OR
len(mail0) > 255 OR
len(manager0) > 255 OR
len(distinguished_Name0) > 255 OR
len(Full_User_Name0) > 255 OR
len(Name0) > 255 OR
len(Unique_User_Name0) > 255 OR
len(Windows_NT_Domain0) > 255 OR
len(company0) > 255 OR
len(DisplayName0) > 255
select * from v_RA_User_UserOUName
where
len(User_OU_Name0) > 512


Cause

A DataSync can fail as a result of source data being too large to fit within the proper field in the App Portal database. In this case, the DataSync.log will show something similar to:
String or binary data would be truncated.
The statement has been terminated.    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at AppPortal.Business.SqlService.ExecuteSQL(SqlConnection connection, String sql, List`1 parameters)
   at AppPortal.Business.Common.ImportDeploymentResources.ImportCMUsers(Boolean isCM12)


Resolution

In most cases where this occurs, the issue is specific to the postalCode field. Although Active Directory allows a postalCode with a length of up to 40 characters, the App Portal database field for postalCode can only hold 42. This is a bug currently being tracked as IOJ-1748247.

To workaround the problem for the time being, the App Portal database can be modified to expand the width of the postalCode field by running the following against the App Portal DB:
ALTER TABLE [WD_User]
ALTER COLUMN [PostalCode] nvarchar(40)

Labels (1)
Was this article helpful? Yes No
No ratings
Version history
Revision #:
1 of 1
Last update:
‎Oct 19, 2018 05:21 PM
Updated by: