How to configure a trusted SQL Server connection
Posted: 15.07.2013, 01:37
G'day,
I'm using ZEOSLib 7.1.0-alfa. Lazarus 1.0.8/SVN 40573/win32/fpc 2.6.2. OS: Win 7, 32 bit.
With TZConnection.Protocol set to either mssql, FreeTDS_MsSQL>=2005 or FreeTDS_MsSQL-2000 I am unable to work out how to connect to a database configured only for "Windows Authentication"
This isn't a DLL issue. It took me an embarrasingly long time to solve that (nicked nwdblib.dll from SQL Server 2000 SP4 for Protocol=mssql, and added msvcr100.dll along with msdblibr.dll for Protocol=FreeTDS_XXX)
I can make a connection to a test database if I specify a database user/password. Unfortunately the database I need to connect to is only configured for "Windows Authentication Mode", and simply leaving User/Password blank on TZConnection raises the error "The user is not associated with a trusted SQL Server connection".
Also, this isn't a database issue. I've confirmed with a variety of tools, including an ADO app written in Delphi a few years back, that my currently logged in user is fully able to connect to the database without passing any configured credentials through.
Someone over on the Lazarus forum suggested I try added "trusted=yes" to the Connection Properties. When I do that I get a "NULL DBPROCESS pointer encountered". It was a great idea though as it got me tracing through the code, and finally got me here.
So, anyone any idea what I should be passing into TZConnection.Properties? Or if there is something else I should be trying?
Although I'm currently not doing this in code (IDE only) the equivalent code snippet of what I'm trying is:
Many thanks
Mike
I'm using ZEOSLib 7.1.0-alfa. Lazarus 1.0.8/SVN 40573/win32/fpc 2.6.2. OS: Win 7, 32 bit.
With TZConnection.Protocol set to either mssql, FreeTDS_MsSQL>=2005 or FreeTDS_MsSQL-2000 I am unable to work out how to connect to a database configured only for "Windows Authentication"
This isn't a DLL issue. It took me an embarrasingly long time to solve that (nicked nwdblib.dll from SQL Server 2000 SP4 for Protocol=mssql, and added msvcr100.dll along with msdblibr.dll for Protocol=FreeTDS_XXX)
I can make a connection to a test database if I specify a database user/password. Unfortunately the database I need to connect to is only configured for "Windows Authentication Mode", and simply leaving User/Password blank on TZConnection raises the error "The user is not associated with a trusted SQL Server connection".
Also, this isn't a database issue. I've confirmed with a variety of tools, including an ADO app written in Delphi a few years back, that my currently logged in user is fully able to connect to the database without passing any configured credentials through.
Someone over on the Lazarus forum suggested I try added "trusted=yes" to the Connection Properties. When I do that I get a "NULL DBPROCESS pointer encountered". It was a great idea though as it got me tracing through the code, and finally got me here.
So, anyone any idea what I should be passing into TZConnection.Properties? Or if there is something else I should be trying?
Although I'm currently not doing this in code (IDE only) the equivalent code snippet of what I'm trying is:
Code: Select all
ZConnection1.HostName := '192.168.100.111';
ZConnection1.Database := 'Pipeline_2013';
ZConnection1.Protocol := 'mssql'; (I'm assuming this is a string and not an enumerated type, which it may be - as I say, I'm playing with IDE only for now)
// ZConnection1.User := 'sa'; // When uncommented works on a test database, sa not configured for the database I NEED to connect to...
// ZConnection1.Password := 'sa1234';
ZConnection.Properties.Add('trusted=yes');
ZConnection1.Connected := True; // <--- Error raised here...
Mike