ASP Connection String for Privileged Account

S

sucaba.r

I don't know if this is a unique problem, or I'm going about it the
wrong way. I currently connect to one of our SQL servers via a
priviliged account (by using RUNAS). Works with no problem. I now
need the ability to connect to the same SQL server using ASP. I have
the following connect string, but I'm not sure how to specify the
domain in the string, or is there some other way?

<%
Set demoConn = Server.CreateObject("ADODB.Connection")
demoPath="DRIVER={SQL Server};" & _
"SERVER=mysqlserver;UID=myusername;" & _
"PWD=mypassword#;DATABASE=qdb"
demoConn.open demoPath
%>

Thanks!
 
B

Bob Barrows [MVP]

I don't know if this is a unique problem, or I'm going about it the
wrong way. I currently connect to one of our SQL servers via a
priviliged account (by using RUNAS). Works with no problem. I now
need the ability to connect to the same SQL server using ASP. I have
the following connect string, but I'm not sure how to specify the
domain in the string, or is there some other way?

First, you need to turn off Anonymous access in your website's Directory
Security settings using IIS Manager.
<%
Set demoConn = Server.CreateObject("ADODB.Connection")
demoPath="DRIVER={SQL Server};" & _
"SERVER=mysqlserver;UID=myusername;" & _
"PWD=mypassword#;DATABASE=qdb"
demoConn.open demoPath
%>

Thanks!

http://www.aspfaq.com/show.asp?id=2126
 
E

Egbert Nierop \(MVP for IIS\)

I don't know if this is a unique problem, or I'm going about it the
wrong way. I currently connect to one of our SQL servers via a
priviliged account (by using RUNAS). Works with no problem. I now
need the ability to connect to the same SQL server using ASP. I have
the following connect string, but I'm not sure how to specify the
domain in the string, or is there some other way?

<%
Set demoConn = Server.CreateObject("ADODB.Connection")
demoPath="DRIVER={SQL Server};" & _
"SERVER=mysqlserver;UID=myusername;" & _
"PWD=mypassword#;DATABASE=qdb"
demoConn.open demoPath
%>
This might work perfect. Including the tip Bob gave.

<%
Set demoConn = CreateObject("ADODB.Connection")
demoPath="Provider=SQLOLEDB" & _
"Data Source=mysqlserver;Integrated Security=SSPI;" & _
"Initial Catalog=qdb"
demoConn.open demoPath
%>
 
S

sucaba.r

I tried your suggestion but got the following error:

Provider cannot be found. It may not be properly installed.
 
S

sucaba.r

Okay, stupid question, but I just realized that I'm not sure I
registered the dll on the right machine. Do I register on the SQL
server or the IIs server that has the ASP scripts?
 
B

Bob Barrows [MVP]

I tried your suggestion but got the following error:

Provider cannot be found. It may not be properly installed.
Actually, if you used this code verbatim, there is a syntax error: it's
missing a semicolon after the word "SQLOLEDB"

demoPath="Provider=SQLOLEDB;" & _
 
B

Bob Barrows [MVP]

On the IIS server.
But see my previous reply.

Okay, stupid question, but I just realized that I'm not sure I
registered the dll on the right machine. Do I register on the SQL
server or the IIs server that has the ASP scripts?
 
S

sucaba.r

I'm back...Now I'm getting the access denied error again:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or
access denied.

Stupid question 2: Where/how are login credentials being taken care of?
 
S

sucaba.r

Stupid question...I know. How/where are login info specified?
I'm back...Now I'm getting the access denied error again:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or
access denied.

http://www.aspfaq.com/show.asp?id=2009 (scroll down almost halfway)
Stupid question 2: Where/how are login credentials being taken care
of?
Huh?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
 
B

Bob Barrows [MVP]

Repeating the question does not clear up the confusion. What are you
talking about? Windows security? SQL Server security?

Stupid question...I know. How/where are login info specified?
I'm back...Now I'm getting the access denied error again:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or
access denied.

http://www.aspfaq.com/show.asp?id=2009 (scroll down almost halfway)
Stupid question 2: Where/how are login credentials being taken care
of?
Huh?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"
 
S

sucaba.r

Authentication is set to Windows and SQL Server. Note that when I
connect to Query Analyzer, I connect using RUNAS then specify domain
and username.

Repeating the question does not clear up the confusion. What are you
talking about? Windows security? SQL Server security?

Stupid question...I know. How/where are login info specified?
(e-mail address removed) wrote:
I'm back...Now I'm getting the access denied error again:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or
access denied.


http://www.aspfaq.com/show.asp?id=2009 (scroll down almost halfway)

Stupid question 2: Where/how are login credentials being taken care
of?
Huh?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
B

Bob Barrows [MVP]

Y-e-e-e-s.
I'm sorry, but that does not make your question any clearer to me. What
"login info" are you asking about. SQL logins? Are you asking how to set
up your users in SQL Server? If so, this is more of a SQL Server
question than an ASP general question (there are newsgroupse devoted to
SQL Server questions: they have "sqlserver" in their names). The answer
depends on if you have Enterprise Manager. Do you have SQL Books Online?
if so, look up Security.

Authentication is set to Windows and SQL Server. Note that when I
connect to Query Analyzer, I connect using RUNAS then specify domain
and username.

Repeating the question does not clear up the confusion. What are you
talking about? Windows security? SQL Server security?

Stupid question...I know. How/where are login info specified?

Bob Barrows [MVP] wrote:
(e-mail address removed) wrote:
I'm back...Now I'm getting the access denied error again:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist
or access denied.


http://www.aspfaq.com/show.asp?id=2009 (scroll down almost halfway)

Stupid question 2: Where/how are login credentials being taken
care of?
Huh?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap
so I don't check it very often. If you must reply off-line, then
remove the "NO SPAM"

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.
 
S

sucaba.r

Sorry Bob. All I'm trying to do is create a connect string with ASP to
log into the same SQL database I use with Query Analyzer and Enterprise
Manager. My confusion is that the connect string from above doesn't
have username/password in the string and I was wondering why not? Are
they implied? Should I be using a different connect string? Sorry for
the confusion.

Y-e-e-e-s.
I'm sorry, but that does not make your question any clearer to me. What
"login info" are you asking about. SQL logins? Are you asking how to set
up your users in SQL Server? If so, this is more of a SQL Server
question than an ASP general question (there are newsgroupse devoted to
SQL Server questions: they have "sqlserver" in their names). The answer
depends on if you have Enterprise Manager. Do you have SQL Books Online?
if so, look up Security.

Authentication is set to Windows and SQL Server. Note that when I
connect to Query Analyzer, I connect using RUNAS then specify domain
and username.

Repeating the question does not clear up the confusion. What are you
talking about? Windows security? SQL Server security?

(e-mail address removed) wrote:
Stupid question...I know. How/where are login info specified?

Bob Barrows [MVP] wrote:
(e-mail address removed) wrote:
I'm back...Now I'm getting the access denied error again:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist
or access denied.


http://www.aspfaq.com/show.asp?id=2009 (scroll down almost halfway)

Stupid question 2: Where/how are login credentials being taken
care of?
Huh?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap
so I don't check it very often. If you must reply off-line, then
remove the "NO SPAM"

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
B

Bob Barrows [MVP]

Ahhh! Now the question is clear!
The line "Integrated Security=SSPI" causes the windows credentials of
the current user to be used to log into the server.
In an ASP application, as long as Anonymous access is disabled, the
current user will be the user whose name appears in the "LOGON_USER"
servervariable. Use this to verify that the user's credentials are being
seen:

Response.Write Request.ServerVariables("LOGON_USER")

But that should have nothing to do with your problem. The "server does
not exist..." error you are seeing is happening even before the login
is attempted. You should Response.Write your connection string and make
sure you have no typos.

Sorry Bob. All I'm trying to do is create a connect string with ASP
to log into the same SQL database I use with Query Analyzer and
Enterprise Manager. My confusion is that the connect string from
above doesn't have username/password in the string and I was
wondering why not? Are they implied? Should I be using a different
connect string? Sorry for the confusion.

Y-e-e-e-s.
I'm sorry, but that does not make your question any clearer to me.
What "login info" are you asking about. SQL logins? Are you asking
how to set up your users in SQL Server? If so, this is more of a SQL
Server question than an ASP general question (there are newsgroupse
devoted to SQL Server questions: they have "sqlserver" in their
names). The answer depends on if you have Enterprise Manager. Do you
have SQL Books Online? if so, look up Security.

Authentication is set to Windows and SQL Server. Note that when I
connect to Query Analyzer, I connect using RUNAS then specify domain
and username.


Bob Barrows [MVP] wrote:
Repeating the question does not clear up the confusion. What are
you talking about? Windows security? SQL Server security?

(e-mail address removed) wrote:
Stupid question...I know. How/where are login info specified?

Bob Barrows [MVP] wrote:
(e-mail address removed) wrote:
I'm back...Now I'm getting the access denied error again:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist
or access denied.


http://www.aspfaq.com/show.asp?id=2009 (scroll down almost
halfway)

Stupid question 2: Where/how are login credentials being taken
care of?
Huh?
 
S

sucaba.r

Aha! Now I can see the logon credentials. Per your suggestion, I
tried to write.response my connect string, but got the same error.
Here's what I tried:

response.write demopath

Ahhh! Now the question is clear!
The line "Integrated Security=SSPI" causes the windows credentials of
the current user to be used to log into the server.
In an ASP application, as long as Anonymous access is disabled, the
current user will be the user whose name appears in the "LOGON_USER"
servervariable. Use this to verify that the user's credentials are being
seen:

Response.Write Request.ServerVariables("LOGON_USER")

But that should have nothing to do with your problem. The "server does
not exist..." error you are seeing is happening even before the login
is attempted. You should Response.Write your connection string and make
sure you have no typos.

Sorry Bob. All I'm trying to do is create a connect string with ASP
to log into the same SQL database I use with Query Analyzer and
Enterprise Manager. My confusion is that the connect string from
above doesn't have username/password in the string and I was
wondering why not? Are they implied? Should I be using a different
connect string? Sorry for the confusion.

Y-e-e-e-s.
I'm sorry, but that does not make your question any clearer to me.
What "login info" are you asking about. SQL logins? Are you asking
how to set up your users in SQL Server? If so, this is more of a SQL
Server question than an ASP general question (there are newsgroupse
devoted to SQL Server questions: they have "sqlserver" in their
names). The answer depends on if you have Enterprise Manager. Do you
have SQL Books Online? if so, look up Security.

(e-mail address removed) wrote:
Authentication is set to Windows and SQL Server. Note that when I
connect to Query Analyzer, I connect using RUNAS then specify domain
and username.


Bob Barrows [MVP] wrote:
Repeating the question does not clear up the confusion. What are
you talking about? Windows security? SQL Server security?

(e-mail address removed) wrote:
Stupid question...I know. How/where are login info specified?

Bob Barrows [MVP] wrote:
(e-mail address removed) wrote:
I'm back...Now I'm getting the access denied error again:

[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist
or access denied.


http://www.aspfaq.com/show.asp?id=2009 (scroll down almost
halfway)

Stupid question 2: Where/how are login credentials being taken
care of?
Huh?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top