IDC: Error Performing Query, Not Defined as a Valid User
Last reviewed: April 22, 1997
Article ID: Q149425  The information in this article applies to: 
Microsoft Internet Information Server version 1.0 
SYMPTOMS
When you access an IDC script, you may receive the following error message: 
   Error Performing Query
   *[State=3700][Error=18450][Microsoft][ODBC SQL Driver][SQL Server]
   Login failed- User: _ Reason: Not defined as a valid user of a
   trusted SQL Server Connection.CAUSE
The error message above may occur in the following conditions: Your SQL Server is not the same computer as your Internet Information Server (IIS). 
You are using Microsoft Windows NT Challenge/Response authentication on IIS. 
You are using Integrated or Mixed Security on the Microsoft SQL Server. 
You are not are not providing the Username: or Password: values in your IDC Script. WORKAROUNDS
There are two possible workarounds: Install SQL Server on the same computer as the Internet Information Server and set up your ODBC System DSN to be Local Server instead or a remote computer name. -or- 
Use Basic Authentication instead of Windows NT Challenge/Response (for example, the user will be prompted to login using a dialog box) MORE INFORMATION
When the client executes the IDC script, IIS must determine whether the datasource is local or remote. If the datasource defined as Local System, the query is passed to the SQL Server on the same computer. If the datasource is remote, IIS must make a network connection to SQL Server. When it does, it does not pass the credentials of user logged on to the client computer; instead, it passes a blank username and password. The SQL Server tries to validate a user without a username; it fails, and it returns the following message to IIS: 
   Login failed- User: _ Reason: Not defined as a
    valid user of a trusted SQL Server ConnectionThe Internet Information Server then passes the results of the query to the client web browser. 
 
--------------------------------------------------------------------------------Additional query words: prodiis winnt
Keywords : iishowto kbnetwork
Version : 1.0 3.51
Platform : WINDOWS
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Last reviewed: April 22, 1997 
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.
 
basic authenticationA security mechanism using a standard HTTP mechanism in which user information is sent received as clear text. (The term clear text indicates data is transmitted as clearly readable text characters rather than binary bit-streamed information, which is not text-formatted.) Passwords and user names are encoded but not encrypted in this type of authentication.challenge/response authenticationA security mechanism in which a client computer uses its established user logon information to identify itself to the server computer. The user is not prompted to enter these user credentials. Instead, the information is available after the user first logs on to a Microsoft® Windows NT®-based computer.
上面这段文字是由MSDN中摘录的。
错误产生原因:IIS在执行数据库连接时要进行用户的登录,这在SQL SERVER与IIS同一机上时很容易做到,但当不在同一机而要登录到另一台机器上时会由于找不到用户登录信息出错。
解决方法:把IIS和SQL SERVER放在一台机器上或修改SQL SERVER的安全验证方式为basic authentication,比如说提示输入用户名和密码再进行登录或在程序以预定用户名登录。