Solved

Trouble using connection string to authenticate on SQL Server

Posted on 2011-02-13
5
394 Views
Last Modified: 2012-05-11
The following connection string works fine when I'm already logged in to a computer on our intranet:

"Server=sname;User ID=my.name;Database=DatabaseName;Trusted_Connection=true"

But from home, using a VPN connection into the intranet, the connection string fails because I'm obviously not "logged in".

I tried the obvious approach of adding my password:

"Server=sname;User ID=my.name;Database=DatabaseName;Password=secret;Trusted_Connection=true"

But this doesn't work. For future reference, I normally log on to a computer named
"Corp123" with a domain of "corpdomain".

I'm using SQL Server 2008, and Visual Studio 2010 to perform the connection using C#.

If source is my connection string, then the following is the code I use to log in from C#:
               SqlConnection conn = new SqlConnection(source);
                conn.Open();
                SqlCommand cmd = new SqlCommand(@"StoredProcedureName", conn);
              ....


I appreciate any help anyone can give. I believe, most likely, that I have the permission to access the database as long as my connection string contains authentication information. But if it's likely I need special rights, please tell me what specific rights I need to ask for from my database adminsitrator. (My DBA's head pops off in response to vague security requests).
0
Comment
Question by:Ryan94114
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34884216
it means that indeed, the SQL Server cannot tell your current windows login information.
and using windows authenticaation will only work if the sql server can "tell" your windows login.
otherwise, you will need to use sql logins.
0
 

Author Comment

by:Ryan94114
ID: 34884636
Reading your message, I have no idea (a) whether or not I may be able to log in using a connection string, and (b) what request to my database admin would result in success.

Remember, I do have access to my own username and password, and can supply them in the connection string if this is helpful.

in summary, does your answer mean (a) or (b) below:

                 (a)  I need to supply authentication information _within_ the connection string, in which case the question becomes what changes are needed to the string in order to authenticate?

                  or

                 (b) a username must be added to SQL Server 2008 before any such connection string would work

0
 

Author Comment

by:Ryan94114
ID: 34884648
A tertiary possibility is that VPN's permit logging on to the network, in which case the question would become, how does one log in remotely to a vpn network to satisfy a SQL Server database. on that vpn.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 34885711
you cannot supply windows login information yourself in the connection string.

so, either your local windows machine login information must be added (as windows login) to the sql logins (however, I am not sure if the SQL Server can resolve - and hence trust - the remote login source... )
otherwise, you need indeed a classic sql login created in the sql logins, and THAT login/password shall be passed in the connection string, but you then need to remove the part "trusted_connection ..."
0
 
LVL 11

Expert Comment

by:mattibutt
ID: 34886166
You can try mssql management studio to see whether you can login using your sql username and password another thing you try is the ip address for connection string instead pf server name
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question