1

To express myself better i start by example.

In my client server application there is a users table.

Each user is mapped to a sql server user.

The database is full of tables, anyway each user can query just 1 table.

The table contains the following information:

  • the version of the database (so the client app can check whether the database version matches with the client version)

  • the db admin login name (tipically "sa")

  • the db admin password (this is encrypted with custom algorithm for security - please note i install a dedicated Sql Server Instance for my applciation)

I make sure each user can query just a table by executing for each user:

GRANT SELECT ON ConnectionTable TO LoginName

So the full flow is:

1) the user inserts username/password

2) the client application retrieves all the info from ConnectionTable

3) the client applicaion decrytpts the sa password

4) the client application logs in as sa so all tables are visible and editable

Now this is what i have (legacy) and I cannot change it.

Somehow this "custom login trick" has been done to avoid to write somewhere on the client the sa password, many client server software i know in fact all use sa to connect and user/password are just two fields of a simple USERS table, but the real connection string is somehow (with a certain degree of security) saved on a file in each client; in my case the "connection string" is stored in the database so as a user logs in to the database (even if with a user that has a restricted access) he gets all he needs to succesfully login.

Since i install Sql Server in mixed mode i support also Windows AUthentication.

So at login the user has a switch to choose between SQl Server and Windows Authentication, as it happens when connecting to SS Management Studio.

What i am trying to achieve now is to login as another user.

I would like that the user checks "Windows Authentication" but he/she can still type the username and the password.

My application is written in Delphi using the SDAC components. As far as i understand SDAC does not allow to perform what i need to do, but i could change only the login part using anothe DAC (Firedac for example). My goal is to login as another windows user.

The final goal is to query ConnectionTable so that i can retrieve the encrypted sa password and login.

So my question is: is it possible (in Delphi Seattle VCL Application) to login to a Sql Server database by setting a windos user different than the current logged in user?

UPDATE:

To better explain my need i describe the real scenario that generates my requirement. I created a web applciation (using VCL for the web) that uses the same authentication method as my client server application does. Imagine my user is MyDomain\MyUser, when I am in LAN i will use Windows authentication to login, but when I login let's say from my Android Phone I would like to login as MyDomain\MyUser by providing password. This is the case, in fact i do not need to impersonate other users, i just want to login with my user when i am not logged in on a Windows pc in a LAN. So somohow at the login screen of my application i would like to choose Auth: Win/SQL and in case Win is chosen, i would like to pass the actual username and password to login. I hope this clarifies more the scenario.

Moreover i also host my application in the cloud and in this case all users are WIndows authentication users of a domain that i created for administratrive purposes, and each user needs to provide username and password to login.

My request comes from the fact that I always supposd that Winows Authentication = LDAP and therefore in LDAP it is possible to specify user and password, while in sql server it looks somehow user is pre-defined (and = to the logged in user) in case of Windows authentication.

UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
  • Why do you think you need to login using the credentials of a Windows account rather than a Sql Server one? – MartynA May 08 '17 at 11:45
  • @MartynA Each user is mapped to a user, If the user "MartynA" is linked to a Win auth user and i want to login as MartynA I need to login as a Windows user. please read the UPDATE i published above to better reply to you. – UnDiUdin May 08 '17 at 12:00

0 Answers0