Re: How to connect via windows authentication?

Velichko Yuriy <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAN=WvWssPuKfpkbaf5uP2BDndCs2V=ymoGXY1xiSNDKvZV7c-A@mail.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 <[email protected]> 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 <[email protected]>
> 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 <[email protected]>
>> 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 <[email protected]> wrote:
>>>
>>>> 2015-03-13 14:09 GMT+00:00 Velichko Yuriy <[email protected]>:
>>>> > 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
>>>> [email protected]
>>>> http://lists.ibiblio.org/mailman/listinfo/freetds
>>>>
>>>
>>>
>>>
>>> --
>>> ​С уважением, Величко Юрий.
>>>
>>
>>
>>
>> --
>> ​С уважением, Величко Юрий.
>>
>
>
>
> --
> ​С уважением, Величко Юрий.
>



-- 
​С уважением, Величко Юрий.
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.