#1 2021-12-31 12:20:32

larand54
Member
Registered: 2018-12-25
Posts: 104

Login fails using TSynConnectionDefinition

It looked to be convenient to use "TSynConnectionDefinition" but I failed to make it work.
Login failed due to missing password.

My code look like this:

fStore: TSynConnectionDefinition;
 
 fStore := TSynConnectionDefinition.CreateFromJSON(StringToUtf8('{	"Kind": "TOleDBMSSQL2012ConnectionProperties", '
          + '"ServerName": "MyServer\\SQLEXPRESS", "DatabaseName": "MyDB", "User": "username", "Password": "myPassword"}'));
    fDBServer := TSQLRestExternalDBCreate(fModel, fStore, false, []);

TSQLRestExternalDBCreate looks for fStore.PasWordPlain which does not exist in fStore.

What's wrong with my assumption?


Delphi-11, WIN10

Offline

#2 2022-01-01 00:01:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,653
Website

Re: Login fails using TSynConnectionDefinition

The password is encoded IIRC.

Start from a TSynConnectionDefinition instance, then serialize it.

Offline

#3 2022-01-01 12:46:19

larand54
Member
Registered: 2018-12-25
Posts: 104

Re: Login fails using TSynConnectionDefinition

I don't understand exactly what you meant but I did like this:

fStore: TSynConnectionDefinition;
pw: RawUTF8
    pw := TSynConnectionDefinition.ComputePassword('myPassword');
    fStore := TSynConnectionDefinition.CreateFromJSON(StringToUtf8('{	"Kind": "TOleDBMSSQL2012ConnectionProperties", '
          + '"ServerName": "MyServer\\SQLEXPRESS", "DatabaseName": "MyDB", "User": "username", "Password":  "'+pw+'"}'));
    fDBServer := TSQLRestExternalDBCreate(fModel, fStore, USE_AUTHORIZATION, []);

And that worked, but that wasn't exactly what you said?

Last edited by larand54 (2022-01-01 19:22:49)


Delphi-11, WIN10

Offline

Board footer

Powered by FluxBB