my connection string goes like this...

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDB;Data Source=mysource

I am using windows authentication, iis 7 and Classic ASP to to connect to SQL express 2008.
Using UDL i can connect to my SQL.
I can also connect to my SQLExpress when i am running my Database management studio.

my problem is that i cannot connect to my datasource and response "Cannot open database "mysource" requested by the login. The login failed." upon connecting via asp pages.

I have tried setting my IIS7 to use windows authentication but the problem is that i don't want to go trhough the usual login page that prompts and created my own login pages that is connected to my AD.

Can anyone help me?

Regards.

Dani AI

Generated

Most likely cause: the IIS/Classic‑ASP process is connecting with a different Windows account than the one used when testing with UDL or SSMS. A UDL test (and SSMS when run interactively) uses the current interactive user’s token, while an IIS worker for Classic ASP uses the application‑pool identity (or whatever identity is configured/impersonated). (learn.microsoft.com)

Practical steps to fix it:

  • Check the application pool identity in IIS Manager (Advanced Settings → Identity). Grant that exact Windows account a SQL Server login and map it to the target database, or change the pool to run as a dedicated domain service account and give that account DB permissions. Integrated (Windows) authentication in a connection string causes SQL Server to use the process’s Windows token. (learn.microsoft.com)

Example T‑SQL to create a Windows login and map it (adjust names and roles to least privilege):

CREATE LOGIN [MYDOMAIN\WebSvcAcct] FROM WINDOWS;
USE MyDB;
CREATE USER [MYDOMAIN\WebSvcAcct] FOR LOGIN [MYDOMAIN\WebSvcAcct];
EXEC sp_addrolemember 'db_datareader', 'MYDOMAIN\WebSvcAcct';

(Grant broader roles only if required.) (learn.microsoft.com)

If the app must run DB calls as the authenticated AD user (not a service account), the deployment requires Kerberos delegation and correct SPN configuration (the “double‑hop” scenario). Otherwise, using a service account for the app pool or switching to SQL authentication are simpler alternatives (as suggested by ). (learn.microsoft.com)

Quick checklist: run a UDL test from the web server, confirm the app‑pool identity, ensure that account exists as a SQL login and is mapped to the correct database (and that the database name/default DB is correct). Avoid granting sysadmin/db_owner unless necessary.

Recommended Answers

All 5 Replies

Have u created the datasource(database driver)?
if not, then create it.

Have u created the datasource(database driver)?
if not, then create it.

yes I have already created one.

connstr="Driver={SQL Server}; Server=adnew.db.5580462.hostedresource.com; Database=adnew; Uid=adnew; Pwd=Whwit123;"
conn.open connstr

i use this script to connect my mdb file

Dim con
    con = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &  Server.MapPath("file.mdb")

It is right

my connection string goes like this...

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDB;Data Source=mysource

I am using windows authentication, iis 7 and Classic ASP to to connect to SQL express 2008.
Using UDL i can connect to my SQL.
I can also connect to my SQLExpress when i am running my Database management studio.

my problem is that i cannot connect to my datasource and response "Cannot open database "mysource" requested by the login. The login failed." upon connecting via asp pages.

I have tried setting my IIS7 to use windows authentication but the problem is that i don't want to go trhough the usual login page that prompts and created my own login pages that is connected to my AD.

Can anyone help me?

Regards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.