473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

SQL Connection String using Domain Account


Folks,

I am working on a .Net web site that connects to SQL Server 2000 on another
box. The DBA has given me a Domain user account with rights to the database
and table. I have confirmed with Query Analyzer that the user ID and
password are good and can access the correct tables. However, I am unable
to get a connection to the database. I either get a Login Failed for (NULL)
user. or Not a Trusted Connection, or Login failed for userID. I have a
felling that I am just using the wrong connection string but each one that I
have tried still fails. The end user must login to the site and it set up
as integrated, but I am not able to use the users ID since they do not have
access to the database.
Here is what I have tried so far.

SqlConnection sqlCON = new SqlConnection(@"Password=Password;User
ID=Domain\userID;Data Source=ServerName\ServerInstance;Initial
Catalog=DatabaseName;");

And

SqlConnection sqlCON = new
SqlConnection(@"Server=ServerName\ServerInstance;D atabase=DabaseName;UID=Domain\UserID;PWD=Password" );

I have tried it with and without the domain name. Most of the time I just
get the standard "Login Failed for Domain\UserID" so it appears to be
getting to the server and rejected. I have a feeling that it is treating it
as a standard SQL account and not a domain account.

Anyone know what I am doing wrong?
Tim
Mar 2 '06 #1
4 40979
I think in order to connect as a domain account, your program has to be
running as that domain account user. And then you would use integrated
security to pass those credentials on to sql server.

Or, you can have a username/password set up in sql server - but this would
not be associated with any user accounts. It would just be using up a user
in that sql server. Then you would pass those credentials in the connection
string.

You are sort of trying to combine these 2 together, and that just doesn't
work.

"Tim Sapp" <Ti******@SpamlessCrossmark.Com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

Folks,

I am working on a .Net web site that connects to SQL Server 2000 on
another box. The DBA has given me a Domain user account with rights to
the database and table. I have confirmed with Query Analyzer that the
user ID and password are good and can access the correct tables.
However, I am unable to get a connection to the database. I either get a
Login Failed for (NULL) user. or Not a Trusted Connection, or Login failed
for userID. I have a felling that I am just using the wrong connection
string but each one that I have tried still fails. The end user must
login to the site and it set up as integrated, but I am not able to use
the users ID since they do not have access to the database.
Here is what I have tried so far.

SqlConnection sqlCON = new SqlConnection(@"Password=Password;User
ID=Domain\userID;Data Source=ServerName\ServerInstance;Initial
Catalog=DatabaseName;");

And

SqlConnection sqlCON = new
SqlConnection(@"Server=ServerName\ServerInstance;D atabase=DabaseName;UID=Domain\UserID;PWD=Password" );

I have tried it with and without the domain name. Most of the time I just
get the standard "Login Failed for Domain\UserID" so it appears to be
getting to the server and rejected. I have a feeling that it is treating
it as a standard SQL account and not a domain account.

Anyone know what I am doing wrong?
Tim

Mar 2 '06 #2


Yes I am starting to see that... I have added the Impersonate tag to my
Web.Config but now have the problem that the web site will not run under
that user ID. I have added it to the Administrators group on my dev machine
but I guess I am missing something else.
Tim
"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:OA**************@TK2MSFTNGP14.phx.gbl...
I think in order to connect as a domain account, your program has to be
running as that domain account user. And then you would use integrated
security to pass those credentials on to sql server.

Or, you can have a username/password set up in sql server - but this would
not be associated with any user accounts. It would just be using up a user
in that sql server. Then you would pass those credentials in the
connection string.

You are sort of trying to combine these 2 together, and that just doesn't
work.

"Tim Sapp" <Ti******@SpamlessCrossmark.Com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

Folks,

I am working on a .Net web site that connects to SQL Server 2000 on
another box. The DBA has given me a Domain user account with rights to
the database and table. I have confirmed with Query Analyzer that the
user ID and password are good and can access the correct tables. However,
I am unable to get a connection to the database. I either get a Login
Failed for (NULL) user. or Not a Trusted Connection, or Login failed for
userID. I have a felling that I am just using the wrong connection
string but each one that I have tried still fails. The end user must
login to the site and it set up as integrated, but I am not able to use
the users ID since they do not have access to the database.
Here is what I have tried so far.

SqlConnection sqlCON = new SqlConnection(@"Password=Password;User
ID=Domain\userID;Data Source=ServerName\ServerInstance;Initial
Catalog=DatabaseName;");

And

SqlConnection sqlCON = new
SqlConnection(@"Server=ServerName\ServerInstance;D atabase=DabaseName;UID=Domain\UserID;PWD=Password" );

I have tried it with and without the domain name. Most of the time I
just get the standard "Login Failed for Domain\UserID" so it appears to
be getting to the server and rejected. I have a feeling that it is
treating it as a standard SQL account and not a domain account.

Anyone know what I am doing wrong?
Tim


Mar 2 '06 #3

"Tim Sapp" <Ti******@SpamlessCrossmark.Com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
|
| Folks,
|
| I am working on a .Net web site that connects to SQL Server 2000 on
another
| box. The DBA has given me a Domain user account with rights to the
database
| and table. I have confirmed with Query Analyzer that the user ID and
| password are good and can access the correct tables. However, I am
unable
| to get a connection to the database. I either get a Login Failed for
(NULL)
| user. or Not a Trusted Connection, or Login failed for userID. I have a
| felling that I am just using the wrong connection string but each one that
I
| have tried still fails. The end user must login to the site and it set up
| as integrated, but I am not able to use the users ID since they do not
have
| access to the database.
|
|
| Here is what I have tried so far.
|
| SqlConnection sqlCON = new SqlConnection(@"Password=Password;User
| ID=Domain\userID;Data Source=ServerName\ServerInstance;Initial
| Catalog=DatabaseName;");
|
| And
|
| SqlConnection sqlCON = new
|
SqlConnection(@"Server=ServerName\ServerInstance;D atabase=DabaseName;UID=Domain\UserID;PWD=Password" );
|
| I have tried it with and without the domain name. Most of the time I just
| get the standard "Login Failed for Domain\UserID" so it appears to be
| getting to the server and rejected. I have a feeling that it is treating
it
| as a standard SQL account and not a domain account.
|
| Anyone know what I am doing wrong?
|
|
| Tim

You can map a domain account to a SQL login, see CREATE LOGIN in SQL books
on line.
For instance, following command creates an SQL login that maps to a domain
account
CREATE LOGIN [mydomain\domainAccount] FROM WINDOWS WITH
DEFAULT_DATABASE=MyDB;

Willy.


Mar 2 '06 #4
SqlConnection sqlCON = new SqlConnection(@"Password=Password;User
ID=Domain\userID;Data Source=ServerName\\ServerInstance; Initial
Catalog=DatabaseName;");

Above is your connection string with one change in the data source,
after server name add another "\". I am not quite sure why, but with
our web application last night this was an issue once again.

On some servers we can use simply:

Data Source=ServerName\ServerInstance

On others we will not be able to connect until we:

Data Source=ServerName\\ServerInstance

I am actually researching this right now and ran across this thread and
I hope that you figured out what the problem was already, but if not
this might help you.

Mar 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gram | last post by:
Hello, Can anyone point me to a connection string for ASP to connect to an MS Access database using a username and password? Thanks in advance. Gram
2
by: Maziar Aflatoun | last post by:
Hi guys, I'm using Windows authentication to connect to SQL Server 2000. On my computer the connection is fine. Now if I move it to a remote server, how to I hard code my Username/Password in...
0
by: Scott Rosa | last post by:
We are looking at changing our connection strings to SQL server to use integrated security. We would use connection pools in IIS6 and authentication of the aspnet user against AD to control access...
39
by: sucaba.r | last post by:
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...
2
by: mattheus0525 | last post by:
Hi. I am asked to connect to SQL server to retrieve a record from its table from MS Access directly. Given the following lines of code, I am not able to connect to the SQL server because the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.