Closed Alissonerdx closed 5 years ago
Are you sure that the remote IP and the user has the rights to login?
Yes, locally it is working.
Well, the message says the correct username? I mean, you put xxx
on the connection string and the message says login failed for user xxx
?
I'm pretty sure that this is a SQL problem.
I ran into this too. The issue is that the docs suggest that you can always use the ConnectionStrings:DefaultConnection as an alternative to the proprietary config options. Unfortunately this is only true if the SQL connection is trusted (and works as in the example code's connection string).
If the connection is via an IP # and requires User id and Password in the connection string then it will not work, as the Dapper:Identity SQL Connection code overwrites the embedded User id and Password with empty strings, which naturally results in connection failures.
If you would normally include the User id and Password embedded in the connection string then you must provide separate DapperIdentity connection config with a separate entry for username and password.
I'm not sure why the code insists on emptying out the User id and Password.
@snorith i guess it's because the connectionbuilder. I'll be very appreciated if you make a pull request to fix this issue.
Pull request submitted...
ERROR:
2018-09-27 10:42:52.5350||ERROR|Identity.Dapper.Repositories.UserRepository|Login failed for user ''. System.Data.SqlClient.SqlException (0x80131904): Login failed for user ''. at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
APPSETTINGS:
"ConnectionStrings": { "EGestorBase": "Server=192.168.0.252;Database=EGestorBase;User Id=xxxxx;Password=xxxxx" }, "DapperIdentity": { "ConnectionString": "Server=192.168.0.252;Database=EGestorBase;User Id=xxxxx;Password=xxxxx" }, "DapperIdentityCryptography": { "Key": "RTU0NkM4REYyNzhDRDU5MzEwNjlCNTIyRTY5IUQ0RjI=", "IV": "U29tZVJlYXxseUNvb2xJVg==" },