private void LoadSSPILibrary() { if (TdsParserStateObjectFactory.UseManagedSNI) { return; } // Outer check so we don't acquire lock once it's loaded. if (!s_fSSPILoaded) { lock (s_tdsParserLock) { // re-check inside lock if (!s_fSSPILoaded) { // use local for ref param to defer setting s_maxSSPILength until we know the call succeeded. uint maxLength = 0; if (0 != SNINativeMethodWrapper.SNISecInitPackage(ref maxLength)) { SSPIError(SQLMessage.SSPIInitializeError(), TdsEnums.INIT_SSPI_PACKAGE); } s_maxSSPILength = maxLength; s_fSSPILoaded = true; } } } if (s_maxSSPILength > int.MaxValue) { throw SQL.InvalidSSPIPacketSize(); // SqlBu 332503 } }