[Mono-list] Connecting to a database (VB)

Daniel Morgan monodanmorg at yahoo.com
Tue Nov 2 16:43:03 EDT 2010


My explaination is how to use Mono's SqlClient with Integrated Security currently.  If you can inspect the packets on your machine, you might be able to discover how to get it to work locally.

I have verified a long time ago that Mono's SqlClient can connect to SQL Server using Integrated Security.  You have to specify the windows domain userid and password because there is no way that I know of to get this info from the Windows operationg system. 

To understand this more, read about Domain Logins in FreeTDS.
http://www.freetds.org/userguide/domains.htm

To support NTLM locally, you would need to modify Mono.Data.Tds Tds.cs

If client receives type 2 message from the server with the Negotiate Local Call (0x00004000) flag, then you will need to do things differently to support local authentication. 

http://davenport.sourceforge.net/ntlm.html#localAuthentication





--- On Mon, 11/1/10, mabra at manfbraun.de <mabra at manfbraun.de> wrote:

> From: mabra at manfbraun.de <mabra at manfbraun.de>
> Subject: RE: [Mono-list] Connecting to a database (VB)
> To: "'Daniel Morgan'" <monodanmorg at yahoo.com>, "'mono-list'" <mono-list at lists.ximian.com>, paul at all-the-johnsons.co.uk
> Date: Monday, November 1, 2010, 1:17 PM
> Hello !
> 
> Sorry, I'll really NOT bother you, but I don't trust your
> statement.
> 
> I am administering Windows since the beginning and using
> and developing lots
> of admin tools in C#. What NTLM gives you finally, is an
> access token,
> containing different SIDs [your user, groups, rights etc.].
> If it does not
> contain a "real" domain, it is usually - on windows [even
> with SqlClient] so
> far - able to authenticate to a windows's machine local
> domain. If your
> computer is named "X", you should be able to connect to
> "X\myUser" on this
> local domain with "Integrated Security".
> 
> If this is not working, I would feel bad about mono.
> Or is there something, I think fundamentally wrong??
> I do not have the time shortly, but I'll definitively
> setup
> a XP-VM with mono to try this out later!
> 
> Naturally, as I wrote, specifying "Integrated Security" AND
> specifying
> username and password WILL NEVER work [wether local domain
> nor real domain].
> 
> br++mabra
> 
> 
> -----Original Message-----
> From: mono-list-bounces at lists.ximian.com
> [mailto:mono-list-bounces at lists.ximian.com]
> On Behalf Of Daniel Morgan
> Sent: Monday, November 01, 2010 3:35 PM
> To: mono-list; paul at all-the-johnsons.co.uk
> Subject: Re: [Mono-list] Connecting to a database (VB)
> 
> Mono's SqlClient supports Integrated Security (NTLM), but
> you must be on a
> true windows domain.  A workgroup does not count. You
> also have to give your
> windows domain user id and password.  On Mono's
> SqlClient, you have to give
> your windows domain credentials because Mono is not
> integrated with your
> Windows workstation, nor SQL Server, nor the Windows server
> where the SQL
> Server instance is running.  
> 
> --- On Sun, 10/31/10, Paul F. Johnson <paul at all-the-johnsons.co.uk>
> wrote:
> 
> > From: Paul F. Johnson <paul at all-the-johnsons.co.uk>
> > Subject: [Mono-list] Connecting to a database (VB)
> > To: "mono-list" <mono-list at lists.ximian.com>
> > Date: Sunday, October 31, 2010, 11:16 AM
> > Hi,
> > 
> > I have set up a really simple MS SQL database and am
> trying
> > to connect
> > to it using VB.
> > 
> > Currently, my code looks like this
> > 
> > Dim connstr as String = "Data
> > Source=localhost\SQLEXPRESS;"+"Initial
> > Catalog="Database1\Table1;"+"Integrated
> Security=SSPI;"
> > Dim sql as String = Nothing
> > Dim tables as New ArrayList
> > Dim sqldata as new DataSet
> > Try
> > Dim connect as new SqlConnection(connstr)
> > connect.Open()
> > Dim sqlcomm as new SqlCommand(sql, connect)
> > sqlcomm.CommandText = "Select Name where (Age > 25
> and
> > Hometown =
> > Liverpool);"
> > Dim sqlad = new SqlDataAdapter
> > sqlad.SelectCommand = sqlcomm
> > For i = 0 to 3
> >   sqlad.TableMappings.Add("Table",
> > tables(i).ToString())
> > Next
> > sqlad.Fill(sqldata)
> > connect.Close()
> > Catch ex as SqlException
> > WriteLine("Error " + ex.Message.ToString())
> > End Try
> > 
> > Nothing amazing. The problem is the connection string
> -
> > I've googled
> > around and nothing seems to fit. The exception thrown
> is
> > that it can't
> > log in for user pb5\paul. If I add User Id=paul or
> User
> > Id=pb5\paul, it
> > still won't connect.
> > 
> > What is wrong?
> > 
> > TTFN
> > 
> > Paul
> > 
> > -- 
> > Vertraue mir, ich weiss, was ich mache...
> > 
> > _______________________________________________
> > Mono-list maillist  -  Mono-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> > 
> 
> 
>       
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> 
> 
> 


      


More information about the Mono-list mailing list