Traditionally I have always used our SQL connection with Integrated Security=SSPI. When I run the following command:
KeySP := Connection.NewCommand(‘GetUniqueKey’, stStoredProcedure) ;
I can see in the SQL Profiler the following command:
exec sp_sproc_columns N’GETUNIQUEKEY’, N’DBO’, N’COMSYS’, NULL, @ODBCVer = 3
And you will see this command ran with the NTUsername of the administrator (this is a server) and the LoginName says DOMAIN\administrator.
You will notice the second parameter of the sp_sproc_columns is the owner parameter and what is passed is the ‘DBO’. This works and the program gets the sp parameters.
I do have login name and password in the connection string which is not the administrator, but a specific account… but I guess the Integrated Security=SSPI overrides and uses NT authenticated user of the service running this the login name doesn’t show up in the profiler… just the administrator which is what the service runs as.
HOWEVER… if I change integrated security to false I see it does start using the login name I passed, BUT it makes another change which leads to problems. The command above changes to this:
exec sp_sproc_columns N’GETUNIQUEKEY’, N’MYLOGINNAME’, N’COMSYS’, NULL, @ODBCVer = 3
The second parameter now shows the login name and not dbo which then never returns anything since the owner of these objects is DBO.
Why am I looking to NOT use SSPI? Because we have views we need to query from this service which have security based on the actually logged in user which the view utilizes. And I need to login as the user and not use the NT authority of the service. I have can definitely use there login, but as you can see the sp_sproc_columns command changes which then leads to issues.
How have others dealt with this? Is there a way to either have it pass in NULL (which works) or always be “DBO”.
Greg