473,782 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# - connection to a remote SQL server

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>;passw ord=<pass>;serv er=<IP>,1433;da tabase=<dbname> ;Trusted_connec tion=yes;connec tion 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_connect ion=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
Aug 31 '06 #1
1 6902

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>;passw ord=<pass>;serv er=<IP>,1433;da tabase=<dbname> ;Trusted_connec tion=yes;connec tion 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_connect ion=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
Aug 31 '06 #2

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

Similar topics

1
2295
by: vighnesh | last post by:
Hi All I am dealing a project in ASP.NET in which I have to establish a connection to SQL Server 2000 database,where the database was located on a remote system. For this I have used SQLConnection object and specified the connetion string.But when it comes to establish a connection its giving me the Error that I. Connection string : workstation id=localhost;packet size=4096;user
5
24018
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP
5
8524
by: Mitya Mitriev | last post by:
Hi I created ASP.NET 2.0 web application that uses SQL Server 2000 database and it works perfectly when website and Sql server were on local machine. Then I installed application on production server. Database is placed on another server. I received the error: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings...
10
5797
by: cleo | last post by:
I am migrating from VB6/Access to Visual Basic and SQL Express. I have success writing test code on my local machine and am now setting up tests for deployment to a server. I have installed SQL Express on a Windows 2003 Server. I can connect and create databases on the Remote Server from my local machine using SQL Management Express, so I know Remote Access is working. However, I am unable to connect using a connection string within...
1
1644
by: =?Utf-8?B?TWVuYWth?= | last post by:
i have developed a web application for intranet and it is installed on the Computer name 'Server' and its already installed sql server 2005, never problem when connecting to sql server 2005 on the 'Server', this intranet has another computer named 'B' and it's already exist SQL2000. i want update some data to SQL2005 on 'Server' using in a SQL2000 which have 'B' computer' when connecting to 'B' it return error like bellow. 'An error has...
5
7701
by: OJ | last post by:
Hi, I am at a loss here, I have a c# asp.net website which connects to a remote SQL Server 2000 db via a connection string. If I set the website up in the filesystem and use the inbuilt cassini webserver in VS2005 then everything is rosy. If I then set up the website on the local IIS 5.1 the site no longer connects and returns this error: An error has occurred while establishing a connection to the server. When connecting to SQL Server...
2
4965
by: samadams_2006 | last post by:
Hello, I have a problem that I'm hoping someone will be able to help me resolve. 1) I have a C# Web Site in which I connect to the database: "Install Microsoft SQL Server 2005 Express Edition" via the link on: http://msdn2.microsoft.com/en-us/express/bb410792.aspx
4
1574
by: glbdev | last post by:
Hi. I am having an problem connecting to a remote SQL Server. Other applications (using access) are connection to it but I cannot get it to work through ASP.Net. Here is my connection string: Public Function StringConnection() As String Return "Server=myservername;Database=mydatabasename;User ID=myid;Password=mypassword;" End Function
4
5310
by: chris | last post by:
Hi guys I have a Frontend and Backend DB that works well on my LAN. I use a INI file Path, to access a mapped network connection back to the Backend Data file. Path=F:\Server\Data.mdb I have a situation now that requires a Remote Connection with my
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.