Page 1 of 1

Using SSPI with SQL Server

Posted: Tue 21 Jul 2015 07:53
by Licences AAW
Hi,

I'm facing an issue while trying to connect to a SQL Server with SSPI integrated security.

If my connection string uses "Integrated Security=SSPI", it is accepted by TUniConnection but seems not have any effect.
If my connection string uses "Authentication=Windows", it is refused by TUniConnection as "Authentication" is not a valid parameter name

Of course, if I set manually the specfic option "Authentication" = "auWindows", it works well but my goal is to control ALL connection parameters with the connection string.

My question is: did I do something wrong (some trick I missed somewhere) or is there a problem in UniDac 6.1.5 ?

(In next post, a sample app which shows the problem)

Re: Using SSPI with SQL Server

Posted: Tue 21 Jul 2015 08:01
by Licences AAW

Code: Select all

uses
  System.SysUtils, uni, SQLServerUniProvider, ActiveX;

const
  ConnectionStr = 'Provider Name=SQL Server;Data Source=XXXXX';

var
  connection: TUniConnection;
begin
  try
    CoInitialize(nil);
    connection := TUniConnection.Create(nil);
    try
      connection.LoginPrompt := False;
      try
        connection.ConnectString := ConnectionStr + ';Integrated Security=SSPI';
        connection.Connect;
        writeln('SSPI: connected');
      except
        writeln('SSPI: not connected = ' + Exception(ExceptObject).Message);
      end;

      try
        connection.ConnectString := ConnectionStr + ';Authentication=Windows';
        connection.Connect;
        writeln('Authentication: connected');
      except
        writeln('Authentication: not connected = ' + Exception(ExceptObject).Message);
      end;

      try
        connection.ConnectString := ConnectionStr + ';Integrated Security=SSPI';
        connection.SpecificOptions.Values['SQL Server.Authentication'] := 'auWindows';
        connection.Connect;
        writeln('SSPI+Authentication: connected');
      except
        writeln('SSPI+Authentication: not connected = ' + Exception(ExceptObject).Message);
      end;
    finally
      connection.Free;
      CoUninitialize;
    end;

    readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
and here is the result it produce:

Code: Select all

SSPI: not connected = Login failed for userĀ 'sa'.
Authentication: not connected = Connection parameter name is unknown: Authentication
SSPI+Authentication: connected

Re: Using SSPI with SQL Server

Posted: Mon 27 Jul 2015 11:05
by azyk
Thank you for the information. We have reproduced this problem and are investigating it. We will notify you about the results as any are available.