PC Review


Reply
Thread Tools Rate Thread

C# - connection to a remote SQL server

 
 
=?Utf-8?B?Q2hyaXM=?=
Guest
Posts: n/a
 
      31st Aug 2006
hi
I have big problem. I am writing a small win application. It will work on
remote MS SQL database (2005). Firstly, I need to log on to the server. The
server supports remote connections and sql and windows authentication.
I declared connection string as follows:

conn = new SqlConnection("user
id=<user>;password=<pass>;server=<IP>,1433;database=<dbname>;Trusted_connection=yes;connection timeout=3");

Using that string I can log on ALWAYS. there is no difference in user or
password. Connection is always successful.
If I remove trusted_connection=yes I will be able to connect to only as 'sa'
user. NOTHING else.

I have tested that only on my own sql server.
But my question is: what is wrong??? I would like to log on only for certain
accounts BUT not for all or just for one
 
Reply With Quote
 
 
 
 
Steven Nagy
Guest
Posts: n/a
 
      31st Aug 2006

Possibly the PC you are accessing from has an access Token from the
remove server (not sql server, but win nt)
When you turn on 'trusted', it is my understanding that it is relying
on your win nt authentication, and doesn't actually care what you pass
as a user name and password. You probably need to decide whether you
want to authenticate with trusted auth (nt) or sql auth. If you want to
test with trusted auth, try creating another account on your pc, log
off and on again and run your app. It shouldn't get access because that
new account probably doesn't have access to the remote pc, and won't be
storing a token for access to the remote pc. But if you try to connect
to the remote pc by file share or enterprise manager then this will get
a nt token and then your app is automatically authenticated while
running under the current user.
I'm not sure if this is your exact problem though, and I don't
understand a lot about nt authentication and tokens. So all in all it
could be a really crap answer!

Can you not just create an SQL user (not nt user) on the remote
instance of SQL Server, give it access to your DB, and turn off
'trusted' in your connection string, using the new account? This would
probably be best, unless you expect every user who uses your
application to also have an NT account on the remote server.

Hope this helps and isn't too wishy washy. Have a good day!
Steve


Chris wrote:
> hi
> I have big problem. I am writing a small win application. It will work on
> remote MS SQL database (2005). Firstly, I need to log on to the server. The
> server supports remote connections and sql and windows authentication.
> I declared connection string as follows:
>
> conn = new SqlConnection("user
> id=<user>;password=<pass>;server=<IP>,1433;database=<dbname>;Trusted_connection=yes;connection timeout=3");
>
> Using that string I can log on ALWAYS. there is no difference in user or
> password. Connection is always successful.
> If I remove trusted_connection=yes I will be able to connect to only as 'sa'
> user. NOTHING else.
>
> I have tested that only on my own sql server.
> But my question is: what is wrong??? I would like to log on only for certain
> accounts BUT not for all or just for one


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
An error has occurred while establishing a connection to the server.When connecting to SQL Server 2005, this failure may be caused by the factthat under the default settings SQL Server does not allow remote connections. mina Microsoft VB .NET 0 8th Oct 2008 07:12 AM
An error has occurred while establishing a connection to the server.When connecting to SQL Server 2005, this failure may be caused by the factthat under the default settings SQL Server does not allow remote connections. mina Microsoft Dot NET 0 8th Oct 2008 07:11 AM
FTP loses connection when someone uses Remote Desktop Connection to server Chris Microsoft Windows 2000 Advanced Server 0 10th Mar 2004 06:07 PM
Remote Desktop Connection Over Cicso VPN Client connection to Windows 2000 Terminal Server David H. Windows XP Work Remotely 0 10th Mar 2004 09:03 AM
Re: Remote DB connection to SQL Server Won Lee Microsoft VB .NET 0 21st Aug 2003 02:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:28 AM.