Search code examples
asp.net-mvcdatabaseexceptionsimplemembership

SimpleMembershipProvider WebSecurity.InitializeDatabaseConnection The login from an untrusted domain


I export the database to the server and I've problem. When I start application I see this error

An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

WebSecurity.InitializeDatabaseConnection("DefaultConnection", 
                                         "Users", 
                                         "Id", 
                                         "Nick", 
                                         autoCreateTables: true);

ConnectionString:

<add name="DefaultConnection" 
connectionString="Data Source=SQL5008.Smarterasp.net;Initial Catalog=DB_9CB321_Szklarnia; 
User Id=DB_9CB321_Szklarnia_admin;
Password=mypassword; Integrated Security=True"
providerName="System.Data.SqlClient"/>

Solution

  • I think that you are providing in your connection string UserName and password, so you can change from Integrated Security=True to

    Integrated Security=False
    

    and if the user 'DB_9CB321_Szklarnia_admin' has rights to connect it will work. When Integrated Security=True the userID and password will be ignored and attempt will be made to connect using current domain credentials.