Solved

Trouble using connection string to authenticate on SQL Server

Posted on 2011-02-13
5
396 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

615 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