Sunday, March 25, 2012

Connecting to SQL from IIS

Hi All,
I'm attempting to connect my .asp page to an SQL 2005 server and I'm
receiving the following error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for
user ''. The
user is not associated with a trusted SQL Server connection.
The SQL server is set for mixed authentication and my connection string
points to an ODBC connection on my web server (and it showed that it was
successfully able to connect after the DSN was created). Are there other
steps on my SQL server that need to be performed to allow for authentication
from IIS? I will also post my connection string below from my ASP page:
<%
Const adOpenStatic = 3
Const adLockReadOnly = 1
'Open Connection to Database
set Conn = Server.CreateObject("ADODB.Connection")
qryDSN = "DSN=BT"
Conn.open qryDSN
set rs = Server.CreateObject("ADODB.RecordSet")
sql = "SELECT CO_COMPANY_NAME FROM COMPANIES"
rs.open sql, conn, adOpenStatic, adLockReadOnly
rs.movefirst
do while not rs.EOF
response.Write(rs.fields(0))
loop
%>
Any help is appreciated!!
Joe Corey
MCSE, MCSA, Security+
jcorey@.andrew.cmu.eduIs the DSN using a SQL Authen. or WIndows Authenticatio. I guess it is
using Windows Authentication and the SQL Server is not on the same box
like the IIS Server. If so, and my guess was right, you will have to
enabled the IIS to delegate authentication. More about this can be
found on the MSDN knowledge base article. Simply search for "Delegation
AND SQL SERVER". After setting up a security principal name SPN you
will be able to authenticate the users.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--

No comments:

Post a Comment