Cannot connect with TMSConnection in a service applciation with Win auth
Cannot connect with TMSConnection in a service applciation with Win auth
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 [email protected] 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.
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 [email protected] 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.
Re: Cannot connect with TMSConnection in a service applciation with Win auth
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 .
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 .
Re: Cannot connect with TMSConnection in a service applciation with Win auth
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
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
Re: Cannot connect with TMSConnection in a service applciation with Win auth
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
Thanks
Re: Cannot connect with TMSConnection in a service applciation with Win auth
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.
Re: Cannot connect with TMSConnection in a service applciation with Win auth
We received your sample and replied to your email.
Re: Cannot connect with TMSConnection in a service applciation with Win auth
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.
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.
Re: Cannot connect with TMSConnection in a service applciation with Win auth
A new question is located in this topic: viewtopic.php?f=6&t=35363