Cannot connect with TMSConnection in a service applciation with Win auth

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
brace
Posts: 213
Joined: Wed 14 Feb 2007 08:26

Cannot connect with TMSConnection in a service applciation with Win auth

Post by brace » Thu 04 May 2017 08:46

I am not able to connect with TMSConnection when autentication is auWIndows and I am in a service application.

There seems an issue with service applciation only, because with standalne exe all is fine. In fact i found this problem when working on an intraweb (VCL for the web) project comparing the standalone exe and the service version of it.

Anyway i am able to reproduce it also on a sample project, i am going to send the sample project plus a video that descibes it by email at info@devart.com now.

When the problem occurs in the service there is an exception and the exception messages says that
DBConn : TMSConnection;
///
DbConn.Username := 'MYDOMAIN\USER';
DbConn.Password := 'password';
DbConn.Server := 'SERVER';
DbConn.Database := 'master';
DbConn.Authentication := auWindows;
dbConn.LoginPrompt := false;
DbConn.Connect;

On Connect the exception message says that the user that cannot authenticate is not DOMAIN\USER, but MYDOMAIN\MYCOMPUTERNAME$.

There is one important info you could ask me: why are you passing the password? Because I want to connect with Windows authentication using any user, not necessarly my one. (I want to log in to intraweb application by passing any domain user + password). I am not 100% sure the technique i use is fine, anyway since it works on win32exe and not on service i see there is a problem.

Since this is a very significant problem for me please reply me soon. I suspect this is a SDAC bug, but i cannot be sure.

I am using SDAC 8.01 on Delphi 10 on Windows 7.

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Cannot connect with TMSConnection in a service applciation with Win auth

Post by azyk » Thu 04 May 2017 12:43

If Windows authentication is used to connect to SQL Server, then Windows credentials have a high priority than a custom user/password. More details about this in MSDN blog:
https://blogs.msdn.microsoft.com/spike/ ... oes-first/

Please send us the sample using the contact form at our site: http://www.devart.com/company/contactform.html .

brace
Posts: 213
Joined: Wed 14 Feb 2007 08:26

Re: Cannot connect with TMSConnection in a service applciation with Win auth

Post by brace » Thu 04 May 2017 13:10

Thanks, i sent the sample using the contact form.

In fact what i am trying to achieve (and that it works fine on win application but not on service application) is that the user inserts is windows user and windows password in a intraweb application and the connection in the database occurs with windows authentication with the specified user.

My main issue is that it works with normal windows app but not with service and as i explain in the video i sent you i suspect this is a sdac bug (or i am doing something wrong).
THanks

brace
Posts: 213
Joined: Wed 14 Feb 2007 08:26

Re: Cannot connect with TMSConnection in a service applciation with Win auth

Post by brace » Thu 04 May 2017 13:47

just to be clear and not create confusion: plese try to review the sample i sent you and based on that tell why i cannot connect in the service application.

Thanks

brace
Posts: 213
Joined: Wed 14 Feb 2007 08:26

Re: Cannot connect with TMSConnection in a service applciation with Win auth

Post by brace » Fri 05 May 2017 10:08

Sorry to keep posting, but i'd like to have a reply on the sample i sent you. I hope you can as soon as possible, it something is not clear ask me please. Thanks.

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Cannot connect with TMSConnection in a service applciation with Win auth

Post by azyk » Fri 05 May 2017 11:23

We received your sample and replied to your email.

brace
Posts: 213
Joined: Wed 14 Feb 2007 08:26

Re: Cannot connect with TMSConnection in a service applciation with Win auth

Post by brace » Mon 08 May 2017 12:08

Thanks.

I confirm that service is not an issue, simply when in service i was trying to connect by passing a username and password, sicne WinAuth was set what happened was that the service was connecting with local system user, that being not my user (who is the sql server admin) it was not possible to connect. So to make the service work as the windows application i should run the serve as my user.
So this closes my question and i thank you a lot for the reply.
I will now ask a new question (since this has been answered) to try to solve my problem.

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Cannot connect with TMSConnection in a service applciation with Win auth

Post by azyk » Thu 11 May 2017 13:22

A new question is located in this topic: viewtopic.php?f=6&t=35363

Post Reply