[freetds] How to connect via windows authentication?

Frediano Ziglio freddy77 at gmail.com
Tue Mar 17 07:31:49 EDT 2015


Which version did you try? 0.91 or development? It would be good to
know the error from GetLastError function.

Frediano


2015-03-13 23:32 GMT+00:00 Velichko Yuriy <velichko.yuriy at gmail.com>:
> The function
>
> status = sec_fn->InitializeSecurityContext(&auth->cred, &auth->cred_ctx,
> auth->sname,
> ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_CONNECTION,
> 0, SECURITY_NETWORK_DREP, &in_desc,
> 0, &auth->cred_ctx, &out_desc,
> &attrs, &ts);
>
> return bad value for my case
>
> if (status != SEC_E_OK)
> return TDS_FAIL;
>
> Sorry for such spam. I'll be grateful if somebody can help me to figure out
> the problem of connection establishing
>
>
>
> On 14 March 2015 at 01:16, Velichko Yuriy <velichko.yuriy at gmail.com> wrote:
>
>> Sorry - miss-click.
>>
>> in result DBPROCESS is NULL.
>>
>> I try to debug what happens in dbopen, and figure out tat connection
>> established properly.
>> Problem in function tds_goodread() for stack:
>>
>> > vs_plugin_db_mssql.dll!tds_goodread(tds_socket * tds, unsigned char *
>> buf, int buflen, unsigned char unfinished) Line 437 C
>>   vs_plugin_db_mssql.dll!goodread(tds_socket * tds, unsigned char * buf,
>> int buflen) Line 504 C
>>   vs_plugin_db_mssql.dll!tds_read_packet(tds_socket * tds) Line 530 C
>>   vs_plugin_db_mssql.dll!tds_get_byte(tds_socket * tds) Line 73 C
>>   vs_plugin_db_mssql.dll!tds_process_login_tokens(tds_socket * tds) Line
>> 336 C
>>   vs_plugin_db_mssql.dll!tds_connect(tds_socket * tds, tds_connection *
>> connection, int * p_oserr) Line 469 C
>>   vs_plugin_db_mssql.dll!tds_connect_and_login(tds_socket * tds,
>> tds_connection * connection) Line 510 C
>>   vs_plugin_db_mssql.dll!tdsdbopen(tds_dblib_loginrec * login, const char
>> * server, int msdblib) Line 1232 C
>>
>> Maybe I forgot some params for connection?
>>
>> On 14 March 2015 at 01:06, Velichko Yuriy <velichko.yuriy at gmail.com>
>> wrote:
>>
>>> A little question about  Windows SSPI auth.
>>> My app uses db-lib. The SQL server and app works on the same machine (win
>>> 8.1, SQLServer EXPRESS 12)
>>>
>>> conf file:
>>>
>>> host = localhost
>>> port = 1433
>>> connect timeout = 0
>>> tds version =
>>> 7
>>> .0
>>> use ntlmv2 = yes
>>> client charset = UTF-8
>>>
>>> Code to connect:
>>>
>>> dberrhandle( ...);
>>>     dbmsghandle( ... );
>>>
>>>  DBSETLUSER( login, "" );
>>>     DBSETLPWD(  login,"" );
>>>
>>>     DBPROCESS* conn = dbopen( login, my_app" );
>>>     if( conn )
>>>     {
>>>
>>>     }
>>>     else
>>>     {
>>>        <<<< Goes here
>>>     }
>>>
>>>
>>>
>>>
>>> On 13 March 2015 at 17:03, Velichko Yuriy <velichko.yuriy at gmail.com>
>>> wrote:
>>>
>>>> Thanks!
>>>>
>>>> The first approach works fine. I saw it before but forgot to duplicate
>>>> '\' symbol in the user name, so got an error, very shamefully. )
>>>>
>>>> Second approach needs more time to realisation but I'm sure that I can
>>>> implement it too.
>>>>
>>>> Thanks for the quick answer. Very helpful.
>>>>
>>>> On 13 March 2015 at 16:46, Frediano Ziglio <freddy77 at gmail.com> wrote:
>>>>
>>>>> 2015-03-13 14:09 GMT+00:00 Velichko Yuriy <velichko.yuriy at gmail.com>:
>>>>> > Hello!
>>>>> >
>>>>> > I can't figure out how to connect to SQL Server via windows auth using
>>>>> > fretds library (dblib).
>>>>> >
>>>>> > In examples is shown how to connect via the SQL authentication.
>>>>> >
>>>>> > Is there example for windows auth.
>>>>> > Should I change conf file, or set specific info to the LOGINREC for
>>>>> > dbopen() ?
>>>>>
>>>>> Hi,
>>>>>   there are two way. Use domain username/password or use single sign on.
>>>>>
>>>>> To use domain username/password just specify the domain in your
>>>>> username. Something like "DOMAIN_NAME\\user_name" with your domain
>>>>> password. Could be that you have to use ntlm version 2 (see
>>>>> documentation).
>>>>>
>>>>> The other option is to use Kerberos or on Windows SSPI. The trick is
>>>>> to specify empty strings for username and password. SSPI is used (and
>>>>> available) on Windows and will use your logged on user while on any
>>>>> other machine you have to setup Kerberos and login (kinit usually)
>>>>> before launching your dblib application.
>>>>>
>>>>> Regards,
>>>>>    Frediano
>>>>> _______________________________________________
>>>>> FreeTDS mailing list
>>>>> FreeTDS at lists.ibiblio.org
>>>>> http://lists.ibiblio.org/mailman/listinfo/freetds
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> С уважением, Величко Юрий.
>>>>
>>>
>>>
>>>
>>> --
>>> С уважением, Величко Юрий.
>>>
>>
>>
>>
>> --
>> С уважением, Величко Юрий.
>>
>
>
>
> --
> С уважением, Величко Юрий.
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds


More information about the FreeTDS mailing list