开发者

Error Opening SQL Server Connection on Web Server

Here is my Error:

ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

Here is my connection string at application start up:

MyConnection = New Odbc.OdbcConnection("DRIVER={SQL Server};SERVER=MySqlServer;Trusted_Connection=True;DATABASE=MyDatabase")

Here is part of Web.Config:

<authentication mode="Windows"/> 
<identity impersonate="false"/>

Here is my IIS(7) settings:

Authentication

  • Anonymous Authentication: Disabled
  • ASP.NET Impersonation: Disabled
  • Basic Authentaction: Enabled
  • Digest Authentication: Disabled
  • Forms Authentication开发者_高级运维: Disabled
  • Windows Authentication: Enabled

Connection Strings

  • MyDatabaseConnection: Data Source=MySqlServer;Initial Catalog=MyDatabase;Integrated Security=True
  • LocalSqlServer: data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true


I believe you may have to use ASP.Net Impersonation in this case.

http://weblogs.asp.net/achang/archive/2004/04/15/113866.aspx


As Zach says, you need to change the credentials of the user accessing the database.

So you either need to turn on impersonation as recommended or you should change the user id and password used by the application pool that is used to run your web site. This MSDN article, while a bit old, still applies and should help you do that.


What user account should be used to connect to the database? Your user account, an account on the SQL server, the IIS app pool account?

By default, if you don't give the connection string a username and password, .NET will use the AppPool's credentials, which as Simen says doesn't have sufficient privileges to the SQL server.

If you want to use the credentials of the user accessing the website (probably a bad idea), you need to use impersonation as Thyamine says, but if you want to use a SQL account that is set up for the database, then you need to put the username and password of that user into the connection string. (http://www.sqlstrings.com/SQL-Server-connection-strings.htm)


if your web application is running without Integrated Security. remove the "Allow Anonymous connections" security option. When authenticated by the web server as ANONYMOUS the request will be executed using an identity does not have sufficient privileges to your SQL Server DB.

Edit: If you are running the web server on a separate machine than the client machine you might want to investigate whether the server actually recognizes the account used on the client machine. If the machines are not part of the same security domain, you might even have to go through the questionable procedure of modifying the server's Local Policies --> Security Options --> Network access: Sharing and security model for local accounts to the setting : Classic - local users authenticate as themselves and creating a user account with the same name and password on the server.

You might also want to investigate http logs on the server

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜