0

I'm trying to write a program that will fetch data from a SQL Server database. The program is written on top of the .NET platform using C#. Furthermore, the program will be running on a Linux host (with mono). The problem that I am faced with is connecting to the database from the Linux machine, all of my code works fine from a windows host (since the server uses windows authentication), so my question is this: how can I connect to/authenticate with the SQL Server instance?

I've looked at http://www.mono-project.com/SQLClient, and it says to use a string similar to this: "Server=MyServer;Database=pubs;User ID=MyWindowsDomain\\MyWindowsUserid;Password=MyWindowsPassword;Integrated Security=SSPI" but that is not working. Is there maybe something I can do on the server (not likely that I'll be allowed to, but as a last resort)?

Thanks.

4
  • What is the connection string you are using and are there any errors when you try to connect? Commented Oct 25, 2011 at 15:46
  • The only error is that it cannot authenticate. Commented Oct 25, 2011 at 15:48
  • 1
    The mono link says "However, if you want to use NT Authentication, you must trully be on an NT/2000/2003 Domain." Commented Oct 25, 2011 at 15:50
  • I somehow missed that =\ Commented Oct 25, 2011 at 15:52

3 Answers 3

4

You cannot use sql server integrated authentication with linux, you have to use sql server authentication

Sign up to request clarification or add additional context in comments.

1 Comment

I'm not super sure about how windows authentication works, but do you think there might be a third-party library that does this (I've not found one, but still)? Furthermore, is there a way to force SQL Server authentication, from the client side I mean?
2

As A. DIMO says, you cannot authenticate using integrated security on *NIX. It's not a windows box.

In your SQL Server Management studio, create a login that uses SQL Server authentication and not Windows Authentication. Ensure it has the necessary writes on the database in question.

Next, remove the Integrated Security=SSPI part of the connection string. That should do the trick.

2 Comments

Part of the problem is that I have very limited access to the server: it's for a school project and the server is on a school server. Can one change his own account authentication type? Or would I need an admin to do that?
@mikhailvs you'd have to get the School DBA to create a SQL-Server account for you to connect with. Send him a nice email saying "I love windows, but... ", and make sure to finish it off with lots of <3 and XXXXs.
1

While not a direct answer to your question, this site is useful for almost any connection string question: http://www.connectionstrings.com/.

At the risk of sounding like a commercial: It's your one-stop-shop for connection strings!

1 Comment

+1, Back in the old days it was wotsits file formats that was the melting part of information. That was quickly replaced by connectionstrings.com :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.