varbinary column removes zeroes on objectSid

Nov 20, 2012 at 12:28 PM
Edited Nov 20, 2012 at 12:29 PM

When I'm trying to add an entry netsqlazman_ApplicationGroupsTable I provide objectSid that is generated by SqlAzManSID.NewSqlAzManSid(). Sometimes the guid that is generated ends with two zeroes or more and when adding to database column varbinary(85) the zero is removed by the database. When loading the same sid I get only 15 bytes instead of 16 (zero was removed) - that causes an exception.

Any reason for this particular column not to be binary(16) instead of varbinary(85)?

(that fixes the problem)


azman version

sql server 2008R2

Nov 20, 2012 at 12:43 PM


I chose to use the varbinary(85), because the default SQL server functions (SUSERSID and SUSERNAME) wants just a varbinary(85) to represent SIDs parameters.

A binary(16) would not be sufficient in special cases (i.e. AD forests).

However, this behavior is modeled by the ANSI_PADDING SQL Server variable (ON or OFF).

See here for more information: