nopSolutions/nopCommerce · error · NopException
Data provider supports connection only with login and passwo
Error message
Data provider supports connection only with login and password
What it means
PostgreSqlDataProvider.BuildConnectionString throws NopException when INopConnectionStringInfo.IntegratedSecurity is true. The Npgsql provider in nopCommerce is configured for username/password auth only; there is no SSPI/Windows-auth path, so IntegratedSecurity is rejected before the NpgsqlConnectionStringBuilder is built.
Source
Thrown at src/Libraries/Nop.Data/DataProviders/PostgreSqlDataProvider.cs:371
public virtual async Task<long> GetDatabaseSizeAsync()
{
using var currentConnection = CreateDataConnection();
var result = await currentConnection.QueryToListAsync<long>($"SELECT pg_database_size('{GetConnectionStringBuilder().Database}') / 1024 as sizebytes");
return result.FirstOrDefault();
}
/// <summary>
/// Build the connection string
/// </summary>
/// <param name="nopConnectionString">Connection string info</param>
/// <returns>Connection string</returns>
public virtual string BuildConnectionString(INopConnectionStringInfo nopConnectionString)
{
ArgumentNullException.ThrowIfNull(nopConnectionString);
if (nopConnectionString.IntegratedSecurity)
throw new NopException("Data provider supports connection only with login and password");
var builder = new NpgsqlConnectionStringBuilder
{
Host = nopConnectionString.ServerName,
//Cast DatabaseName to lowercase to avoid case-sensitivity problems
Database = nopConnectionString.DatabaseName.ToLowerInvariant(),
Username = nopConnectionString.Username,
Password = nopConnectionString.Password,
};
return builder.ConnectionString;
}
/// <summary>
/// Gets the name of a foreign key
/// </summary>
/// <param name="foreignTable">Foreign key table</param>
/// <param name="foreignColumn">Foreign key column name</param>View on GitHub (pinned to 64bdf2ff08)
Solutions
- Set IntegratedSecurity=false and provide Username and Password.
- When migrating providers, regenerate the connection configuration rather than reusing the SQL Server one.
- Validate the IntegratedSecurity flag against the selected provider during install.
Example fix
// before info.IntegratedSecurity = true; // from SQL Server template var cs = dataProvider.BuildConnectionString(info); // after info.IntegratedSecurity = false; info.Username = "nop_user"; info.Password = "********"; var cs = dataProvider.BuildConnectionString(info);
Defensive patterns
Strategy: validation
Validate before calling
if (connInfo.IntegratedSecurity)
throw new InvalidOperationException("PostgreSQL provider requires Username/Password; disable IntegratedSecurity.");
var cs = dataProvider.BuildConnectionString(connInfo); Type guard
static bool RequiresSqlAuth(DataProviderType t) => t is DataProviderType.MySql or DataProviderType.PostgreSQL;
Try / catch
try { var cs = dataProvider.BuildConnectionString(connInfo); }
catch (NopException ex) when (ex.Message.Contains("only with login and password"))
{ /* clear IntegratedSecurity, provide Username/Password, rebuild */ } Prevention
- Do not carry IntegratedSecurity=true over from SQL Server configs.
- Always supply Username/Password for PostgreSQL.
- Validate IntegratedSecurity against provider type during install.
When it happens
Trigger: Install/configuration supplies IntegratedSecurity=true for a PostgreSQL connection (commonly inherited from a SQL Server template). The guard fires before connection construction.
Common situations: Switching provider from SQL Server to PostgreSQL without clearing the integrated-security flag; default install model with IntegratedSecurity=true; admin UI checkbox left enabled.
Related errors
- Data provider supports connection only with login and passwo
- ConnectionStringWrongFormat
- Unable to connect to the new database. Please try one more t
- This database provider does not support backup
- Unable to connect to the new database. Please try one more t
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/9c897cbee71948e2.
Report an issue: GitHub.