Sunday, March 25, 2012

connecting to sql from ASP

I created a webpage where someone can enter in new client
info. Using asp, I want to connect to the sql db and add
the new record. I'm using SQL2k in an W2K environment. I
want to use the trusted connection so SQL would use the
windows login to authenticate. Below is the code for
connecting to the sql server:
<%
dim cn, cs
Set Cn = Server.CreateObject("ADODB.Connection")
Cn.open "PROVIDER=SQLOLEDB;DATA
SOURCE=webbus\lab;TRUSTED_CONNECTION=YES;DATABASE= Client"
Set cs = Server.CreateObject("ADODB.Recordset")
cs.Open "SELECT * FROM CallerTest"
%>
When I click the Save button on the webpage to add the new
info, I get this error:
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E4D)
Login failed for user 'WEBBUS\IUSR_WEBBUS'.
/lab/addnew.asp, line 95
Line 95 is the cn.Open line
What am I missing?
Ngan,
trusted security means that it'll use the IUSR_IISCOMPUTERNAME user for
anonymous access by default. This is configurable to another domain user in
IIS on the security tab for your website. If you want to use windows logins,
then you must disable anonymous and have windows integrated impersonation.
HTH,
Paul Ibison
|||How do I go about disabling the anonymous and having the
windows integrated impersonation?
Thanks!

>--Original Message--
>Ngan,
>trusted security means that it'll use the
IUSR_IISCOMPUTERNAME user for
>anonymous access by default. This is configurable to
another domain user in
>IIS on the security tab for your website. If you want to
use windows logins,
>then you must disable anonymous and have windows
integrated impersonation.
>HTH,
>Paul Ibison
>
>.
>
|||Programs, Administrative Tools, IIS. Select the website then right-click
proerties, directory security, edit. Untick enable anonymous access and tick
Integrated Windows Authentication. It's worth reading up on the options here
as if this is an internet site (rather than intranet or extranet) then
you'll need Basic Authentication, preferably with SSL.
HTH,
Paul Ibison
|||Thanks for that info! This will be an intranet website so
I'll just do the integrated windows thingie.
Currently, I have people from our provider companies
connected to me via a T1, so they don't have a windows
login. They are accessing the website anonymously, I
assume. If I turn off the anonymous access, I take it
they won't be able to view the website anymore.
How do I go about giving them "guest" access? Do I give
each company their own user account or group them somehow
into one guest group?
Thanks.
Ngan

>--Original Message--
>Programs, Administrative Tools, IIS. Select the website
then right-click
>proerties, directory security, edit. Untick enable
anonymous access and tick
>Integrated Windows Authentication. It's worth reading up
on the options here
>as if this is an internet site (rather than intranet or
extranet) then
>you'll need Basic Authentication, preferably with SSL.
>HTH,
>Paul Ibison
>
>.
>
|||They can access the site, but the windows login dialog box will come up.
Regards,
Paul Ibison
|||Sorry,
misread your previous post - yes, the previously anonymous users will be
prompted with a windows login dialog box. You'll need to give them a login
they can use. If all people use this login then you might as well go back to
anonymous, but if this is yust a subset of people then creating separate
windows logins makes sense. Alternatively you could use forms logins for
either ASP or ASP.NET.
Regards,
Paul Ibison
sqlsql

No comments:

Post a Comment