Einzelnen Beitrag anzeigen

clues1

Registriert seit: 11. Feb 2004
97 Beiträge
 
#2

Re: ADO > MSSQL: Zweistufige Authentifizierung, aber wie?

  Alt 29. Okt 2004, 13:13
Hi, in meinen EDB Komponenten (siehe Open Source) habe ich das so in etwa gemacht:

Das stand mal irgend wo in der MS SQL Server Doku drinne
Delphi-Quellcode:
function TEDBConnect.CreateDBConnection(AEDBTyp: TEDBTyp; DataSource: string; InitDB: string; UN: String; PW: String; ShowMsg: boolean=false; AccessDBPW: String = ''; WindowsSecurity: boolean=false): boolean;
var
  asTimeout, asDataSource, asUN, asPW, asInitDB, ConnectionString: AnsiString;
  iReturn: Integer;
  OldCursor: TCursor;
begin
  result := false;
  asInitDB := '';
  asUN := '';
  asPW := '';
  LastErrorToZero;
....
                         ConnectionString := 'DRIVER={SQL Server}';
                         asDataSource := ';SERVER='+DataSource;
                         asInitDB := ';Initial Catalog='''+InitDB+'''';


                          if WindowsSecurity then // <------ Wenn Windows Sicherheit dann Integrated Security=SSPI ansonnsten Persist Security Info=True
                             ConnectionString := ConnectionString + ';Integrated Security=SSPI' + ';Persist Security Info=False'
                          else begin
                             ConnectionString := ConnectionString + ';Persist Security Info=True';
                             asUN := UN;
                             asPW := PW;
                          end;// ------>>
                       end;
....
  ConnectionString := ConnectionString + asDataSource;
  if trim(asInitDB) <> 'then
     ConnectionString := ConnectionString + asInitDB;
  if trim(asUN) <> 'then
     ConnectionString := ConnectionString + ';User ID=' + asUN;
  if trim(asPW) <> 'then
     ConnectionString := ConnectionString + ';Password=' + asPW;
  if trim(AccessDBPW) <> 'then
     ConnectionString := ConnectionString + ';Jet OLEDB:Database Password='+AccessDBPW;

// Showmessage(ConnectionString);
  // öffne Eine verbindung mit dem ConnectionString
  if OpenConnection(ConnectionString, ShowMsg, asUN, asPW) then begin
     result := true;
  end;
end;
  Mit Zitat antworten Zitat