Connect to SQL server from Visual Interdev

Connect to SQL server from Visual Interdev

Post by Seb Reev » Thu, 27 May 1999 04:00:00



I have written some ASP vbscript in Interdev to connect to an SQL Server on
my network:

 Set rst = Server.CreateObject("ADODB.Recordset")
 Set con = Server.CreateObject("ADODB.Connection")
 con.Open "...blah..."
 Set rst = con.Execute("authors", , 2)

...just to get a recordset to html.

THE PROBLEM: The connection string I am using does not login to the SQL
Server:

    Microsoft OLE DB Provider for SQL Server error '80004005'

    Login failed- User: _ Reason: Not defined as a valid user of a trusted
SQL Server connection.

    /TestDbASP/default.asp, line 18

BUT: The EXACT same connection string works from VB6.0

ANY IDEAS?

Seb Reeve - Sabio Limited

 
 
 

Connect to SQL server from Visual Interdev

Post by Jeff Dunmal » Thu, 27 May 1999 04:00:00


Seb,

I believe the connection string isn't working from ASP because the security
context is different.  When you try it from VB, you're logged in as
yourself.  I assume your NT account has access to the SQL Server.  When you
try it from IIS, your code is running in the security context of
IUSR_MACHINENAME, assuming you are using anonymous access.  If you're using
NT Challenge/Response, the page will run under the security context of the
NT user you log in as.

The solution is to either:

1) not use a trusted connection with SQL Server.  The is configurable by SQL
Server and would mean you'd pass a username / password to make the
connection.

2) Log in as a user that has access to the database.

3) Make an account that has access to the database, and change IIS so it
uses that account as its anonymous user.  You can change the settings for
the web in IIS 4 under the security tab (if I remember correctly).  Be
careful with the permissions you give this account.  Anyone will access to
your pages with effectively have the same permissions on your network as the
new anonymous account you create.

Anyone else?  Are there other options?

Hope this helps,

Jeff Dunmall

The reason your connection string isn't working from ASP


>I have written some ASP vbscript in Interdev to connect to an SQL Server on
>my network:

> Set rst = Server.CreateObject("ADODB.Recordset")
> Set con = Server.CreateObject("ADODB.Connection")
> con.Open "...blah..."
> Set rst = con.Execute("authors", , 2)

>...just to get a recordset to html.

>THE PROBLEM: The connection string I am using does not login to the SQL
>Server:

>    Microsoft OLE DB Provider for SQL Server error '80004005'

>    Login failed- User: _ Reason: Not defined as a valid user of a trusted
>SQL Server connection.

>    /TestDbASP/default.asp, line 18

>BUT: The EXACT same connection string works from VB6.0

>ANY IDEAS?

>Seb Reeve - Sabio Limited


 
 
 

1. Visual InterDev / IIS Server/ ODBC Connect to SQL Server 6.5

Here's one that's consumed too much of my life already :)

When creating an Active Server Page to connect to an ODBC Datasource, it is
required to hard-code the SQL Server Login/Password in the VBScript line:

<% objDBConnection.Open "PhoneList", "Username", "Password" %>

Where PhoneList is an ODBC DSN on the IIS Server.  This utilizes SQL
Server's Standard Security model over TCP/IP.  SQL Server also supports NT
Integrated Security through Trusted connections over either Named Pipes or
Multi-Protocol network libraries.  I would like to be able to utilize SQL's
Integrated Security to authenticate a user to a database from the client's
browser.

IIS Security allows for an NT Challenge/Response authentication, and you
can even get the name of the currently logged-in NT User from the client's
workstation running the browser. (Request.ServerVariables("LOGON_USER"))
Under standard security for SQL, you can pass this variable as a parameter
to the first line above, and if that SQL Login Name has no password, you're
in.
This requires all login passwords in SQL to be empty, or to manage a
password list yourself in another table somewhere.

Since SQL Server can only establish trusted connections through
Multi-protocol clients, and the browser session is pure TCP/IP, you receive
a general network error when trying to establish a trusted SQL connection
from a browser.

I would like to know if anyone has been able to manage Web-based
authentication to SQL Server through the mechanisms already in place in NT
Server/IIS Server, or if this is an issue to be resolved in future releases
of the products?

2. Message facility in Universe

3. Visual InterDev / IIS / ODBC Connect to SQL Server 6.5

4. SP3

5. How to debug stored procedures in SQL 7.0 using Visual Interdev 6.0 or Visual Basic 6.0

6. How do you call Crystal Reports?

7. SQL Server 2000 functions and Visual Interdev 6.0

8. newbie question: importing records from a portal row

9. Visual Interdev to SQL Server

10. Visual InterDev Connection to SQL Server

11. ADO, Visual InterDev, & SQL Server

12. SQL Server (v6.5) / Visual InterDev / ASP integration help needed

13. JOB OFFER - MS SQL SERVER + MS Visual InterDev