#101 Re: mORMot 1 » Elevate Web Builder » 2016-09-13 20:02:21

edwinsn wrote:

Erick,

>Congratulations!

Thanks.

> Just out of curiosity, why have you choosen EWB other than Smart Mobile Studio?

I'd say it comes down to personal preference. 

I coded programs in SMS first, but I felt they were sloppy and buggy.  Someone on the delphi forum urged me to "just try" EWB ,
and since I had taken similar advice about mormot, I just tried it, and it somehow fit me better.  The apps looked professional and did what
I wanted right away.  It was closer to a Delphi VCL metaphor.

SMS promised new versions for months (a year maybe) to fix some bugs I mentioned but never delivered.  They also recommended
a manual that was years out of date and unfinished, with no warning.  It felt like a dead product 7 months ago, maybe that's changed.

SMS has a more sophisticated Object Pascal than SMS,  EWB implemented less, but I felt it was more solid.

SMS seemed more interested in game development. EWB is focused on database/professional apps.  Both are equally
good at responsive design, but are different.

I guess it's just like how some of us have given up on Delphi, whereas some others don't care for FPC/Lazarus.  I know SMS
supports interfaces natively which EWB does not, but it's not a huge difference in practice because you just rewrite a few lines
of pascal headers... no big deal.

Erick

#102 Re: mORMot 1 » Elevate Web Builder » 2016-09-13 11:04:49

The Elevate Web Builder (EWB) book is available at Amazon: UK, EU and USA.  250 pages are advanced stuff, and 50 pages are introductory to EWB,
but it all assumes you have a good Delphi/FPC background.  There is no introduction to Pascal or OOP or Forms.

I live in Canada, so I actually have to order it from the US store because it's not yet carried in my own country...yet.  My other books are listed everywhere, I think they just have to have enough time/volume to be listed everywhere.  This one was just released on the weekend.
- - -
My current project is a Mormot book, which I've been working on for over a year now.   I'll share it with AB
to fact check as it nears completion. 

Mormot is such a rich environment, I found no shortage of material, but the real challenge was finding a coherent way
to present it accurately.

The Mormot online FAQ is obviously the definitive source for information and will always be that, but I hope to shave
off a lot of the learning curve for new users, and present interesting solutions for existing users.

The book will likely be called Delphi Enterprise Databases Using mORMot and Elevate Web Builder.  I
think they are a perfect fit (with a little help from me).  For advanced users, using only SOA, I
show how to do Active Directory/RADIUS/LDAP based logins from the EWB web client.  I am currently
working on OAuth2 logins too, but that isn't quite done. 

I freqently mention FPC/NewPascal but don't get into the intricacies of FPC/NewPascal because I
consider them a point-in-time challenge best addressed in the FAQ.

mORMot brings compatibility, performance, reliability, scalability, etc. to the table.  And it's a long term
solution because it's not tied to one vendor.  EWB brings a universal client - both through
the web, and as my current EWB book (sorry I'm jumping around here) shows, you can generate
EXEs, OS/X bins, Android APKs, IOS binaries, Win Phone bins, etc.  It's more portable than
FMX, but you can do most things FMX apps can (read bar scanner on your phone, use geolocation, etc.) when
compiled as a native EWB app.

The two give an end-to-end solution in Object Pascal and standards based technologies.

Oddly, I think my books also legitimize the topics for bosses who might be afraid of these technologies.  They are
worried about long term investments in software which is only documented online, or where there is a
steep learning curve and silos of knowledge.  With my books, a new employee can be brought up to
speed quickly, and best practices are shared coherently.

There are about 50 pages of overlap in these two books.  The remaining 250 pages in each are unique.

Erick

#103 Re: mORMot 1 » Elevate Web Builder » 2016-09-13 02:09:30

I'm happy to announce my Elevate Web Builder book (2nd edition) has been published on Amazon and includes
adding mORMot support to Elevate Web Builder, complete with samples using stock mormot servers.

You can download sample HTML/JS and the linking EWB source code at http://www.erickengelke.com

This means: End-to-End pascal as EWB compiles to HTML/JavaScript.

Elevate Web Builder (EWB) is a commercial toolkit similar in many ways to Smart Mobile Studio.  I have licenses
for both, but I no longer use SMS.  The pricing is similar for both products.  I have no commercial interest in
EWB except royalties on my book, but I am a satisfied customer.  I believe they have a trial edition available.

If you have any questions, I'll answer them here, or in Email: erickengelke@gmail.com

#104 Re: mORMot 1 » Delphi for Linux preview - what do you think? » 2016-09-05 20:22:58

I took a look at newpascal.org.  Interesting. 

Questions:
1. How stable would a mormot/NewPascal server be under Linux?  Would you say you are comfortable running it in production?

2.My shop is primarily FreeBSD-based.  How stable is that newpascal version?

3. The RTTI-from-Delphi solution doesn't work for me because my staff are not licensed for Delphi, just me.

Definitely keep up the good work.

#105 mORMot 1 » getting userid string when executing a server interface » 2016-09-04 04:12:58

erick
Replies: 1

Hi,

I'm doing some RPCs, but need to know the userid the code is running as, so I can update the database to who made which changes.

I don't see where I can discover the userid or UID number.  Any help would be appreciated.

#106 Re: mORMot 1 » Delphi for Linux preview - what do you think? » 2016-09-03 17:21:12

According to the mormot docs, FPC can't do server-side SOA due to RTTI limitations.  Has that been fixed yet?

#107 Re: mORMot 1 » Delphi for Linux preview - what do you think? » 2016-09-03 15:00:26

Hi,

I was hopeful that Mormot would support Delphi on Linux, just because debugging with Delphi feels easier.

But I guess I could write/test under windows, then FPC to other platforms.  Actually, for servers we're a FreeBSD shop too, so if FPC supports FreeBSD it would be preferable.  I'll have to try it.

I *really* like the fact that mormot is so flexible that you can make many OS-style decisions at deploy time rather than at project initiation time.

Erick

#108 Re: mORMot 1 » NewPascal preview - fork for mORMot » 2016-08-26 02:05:20

Just adding moral support at this point.   

Coming from the Elevate Web Builder community (Object Pascal for Web, compiles to native JavaScript/HTML)
we are presently talking about options for server code, and many people are post-Delphi in that they don't
carry Embarcadero licenses anymore. 

We are just mashing up mormot with Elevate's product, so I'm pleased to see a glowing future for the free/affordable Pascal server code compatible with mormot.

Erick

#109 Re: mORMot 1 » Elevate Web Builder » 2016-08-23 00:22:06

DKA wrote:

Thanks Erick. Please Let us know when the proofed book will be available.

Tim seems busy with issues of the new release of EWB, so it may take him some time to get to proofing the book.

We were hoping for early september.

#110 Re: mORMot 1 » Elevate Web Builder » 2016-08-17 01:45:07

Sorry, I forgot to mention that the book is still being proofed, so it should be available for september.

Erick

#111 Re: mORMot 1 » Elevate Web Builder » 2016-08-17 01:43:35

DKA wrote:

Erick,
In your book, do you have an SOA example between EWB and Mormot or a chat example like this:
http://matthew-jones.com/ewb-rosdk-getting-started/

Hi DKA,

I have three examples, all use existing Mormot sample servers.  I don't go into Momot server design.

The examples:
1. SOA REST example PUT/POST/GET/DELETE similar to typical Mormot calls
2. TDataSet-based calls, so you can use TGrid and other data-aware components
3. RPC server which also supports the Momot password cryptography, so you can call any
mormot RPC or other call.  I based it on the ICalculator example

I presently have only a cell phone connection and can't upload samples at 3G speeds. 

Erick

#112 Re: mORMot 1 » Elevate Web Builder » 2016-08-10 21:07:04

ab wrote:

You should use the crc32 seed parameter, not concatenate hexadecimal values...

Ahhh, that was my problem.  Solved!

Question:  I see the protocol creates a problem the client has a 1/4billion odds of solving for a Man-in-the-middle attack.  What is to prevent the bad client from trying all 4 billion possibilities?  Do you close the session or do an exponential back off, or blacklist, or what? 

Thanks

#113 Re: mORMot 1 » Elevate Web Builder » 2016-08-03 20:38:18

ab wrote:

IMHO starting from SynCrossPlatformRest.pas may be easier to follow.

The doc has uppercase hex, but I'm assuming it's all lower case hex based on the server-supplied values.

E

#114 Re: mORMot 1 » Elevate Web Builder » 2016-08-03 19:42:57

erick wrote:

in contrast, the javascript samples compute
something like:
       
>     s := IntToHex( crc32(url + IntToHex(crc32(Nonce+authsessionPrivateKey),8)),8);
>   sign := IntToHex( authsessionID, 8) + nonce + s;

>   ? or & session_signature= sign

For mormot.pas I see:

Call.url := Call.url+fSessionIDHexa8+nonce+CardinalToHex(
      crc32(crc32(fSessionPrivateKey,Pointer(nonce),length(nonce)),
      Pointer(blankURI),length(blankURI))



which I interpret as:

     Tix := integer(now) div 256;  // time in 256 ms incremeents

     Nonce := IntToHex( Tix, 8 );
                                                             
     s := IntTOHex( crc32( authsessionprivatekey + nonce ),8);
     s := IntToHex( crc32( s + url),8);
    sign := IntToHex( authsessionID, 8) + nonce + s;

    prf := '?';
    if Pos('?',url) > 0 then  prf := '&';
    result :=  prf + 'session_signature=' + sign;

but I'm obviously wrong.

#115 Re: mORMot 1 » Elevate Web Builder » 2016-08-03 18:27:24

in contrast, the javascript samples compute
something like:

     Tix := integer(now) div 256;  // time in 256 ms incremeents

     Nonce := IntToHex( Tix, 8 );
       
     s := IntToHex( crc32(url + IntToHex(crc32(Nonce+authsessionPrivateKey),8)),8);
    sign := IntToHex( authsessionID, 8) + nonce + s;

   ? or & session_signature= sign

But that 8x3 hex number doesn't work either.  I get 404 error

Erick

#116 Re: mORMot 1 » Elevate Web Builder » 2016-08-03 17:57:53

Okay, my current problem is the session_signature value


>The URI signature, using the session private key, the user hashed password, and the supplied Client Time Stamp as source for its crc32 hashing algorithm.
...
>In this case, 0000004C is the Session ID, 000F6BE3 is the client time stamp (aka nonce), and 65D8D454 is the signature, computed by the following Delphi >expression:

(crc32(crc32(fPrivateSaltHash,PTimeStamp,8),pointer(aURL),aURLlength)=aSignature);

and PrivateSaltHash = sha1('salt'+password )

Where is the server-returned private key used in this formula, I don't see it.  That's probably why my code isn't working

Also, is aURLLength in decimal or hex or 8 character hex?

Thanks

#117 Re: mORMot 1 » Elevate Web Builder » 2016-08-02 23:11:22

I think I got authentication working.  Yea.

Now I'm on to the Calculator.add example.

The _contract_ is not documented as far as I can see.  I tried a couple of things,
both with an empty JSON [] and no JSON.  According to my browser the SMS
example sends an empty JSON.  Anyways I get no info from the server to help me
debug it.

I've put the example up at http://dark.uwaterloo.ca/temp/sample3.zip
if anyone is willing to take a look.  You just run the HTML file.  You can see the
uploads/downloads in the browser's F12 mode.

Thanks for any info you can supply on what I'm doing wrong. 

Thanks
Erick

#118 Re: mORMot 1 » Elevate Web Builder » 2016-08-02 17:18:55

I found the source code easier to read than the page.
But the example from javascript
http://synopse.info/forum/viewtopic.php?id=490&p=2
shows hexpasswordhash=sha256( 'salt' + password )
where 'salt' is unexplained, so I think they mean the word said
which doesn't seem compatible with the documentation.

#119 Re: mORMot 1 » Elevate Web Builder » 2016-08-02 15:40:09

I'm trying to figure out the protocol.  What I think it is goes like this.
Have I got it right?

Login
------

Send: GET //host/root/Auth?UserName=clientname

returns
  { result : servernonce}

GET //host/root/Auth?UserName=clientname&Password=xxxxxxxxxxxxxxxx

where xxxxxxxxxxxxxxx = sha256hash( 'root' + servernonce + clientnonce
                      + clientname + passwordhashhexa )
and passwordhashexa = sha256hash( "salt" + password )
Where "salt" is actually the word: salt

Logout
GET //host/root/Auth?UserName=clientname&session=n


Signing Typical Message
...&session_signature=xxxxxxxxyyyyyyyyzzzzzzzzzzzzzzzz

xxxxxxxx = session  ID with leading zeros
yyyyyyyy = nonce
zzzzzzzzzzzzzzzz = crc32( url + crc32( nonce + sessionprivatekey))

I don't think I have it right.  Please help.

Thanks
Erick

#120 Re: mORMot 1 » Elevate Web Builder » 2016-08-02 14:13:01

My Mormot/EWB interfacing code will probably be hosted on Elevate's public web space
in the coming weeks after I have it more finalized.  I'm still rejigging major parts to
match the specifics of Mormot and the latest EWB Beta 2.05.

It will be a free library.  Documentation for it and EWB in general will be in my updated
book which will be released probably by September.

#121 Re: mORMot 1 » Elevate Web Builder » 2016-08-02 01:20:13

Thanks for the reply on OAuth.  I read it briefly and will study it in detail later, as a lot of things I do rely on it.

Erick

#122 Re: mORMot 1 » Elevate Web Builder » 2016-07-31 20:35:57

ab wrote:

AFAIR JWT token is not safe from MIM attacks.

True, unless it is used with OAuth 2, then it is safe.

Erick

#123 Re: mORMot 1 » Elevate Web Builder » 2016-07-31 17:22:09

Section 21 in the documentation talks about a few  methods of storing credentials.
You might want to look at JWT.

The concept is this: you authenticate once the usual ways, then return the userid + other needed
session fields to the client in a JWT token.  But the token is a signed JSON string.  When the JWT
is submitted again in the future, you onlyneed to verify the HASH is valid - if the hash computes, then
the user is properly returning the session information.

Unlike cookies, JWT is stateless.

see JWT.IO for details including Delphi libraries.

JWT is portable technology and libraries exist for many languages.

Erick

#124 mORMot 1 » Elevate Web Builder » 2016-07-31 16:49:42

erick
Replies: 57

Okay, I have the following working on Elevate Web Builder
  - GETting a full list of all elements, or one element by ID
  - DELETing elements by ID
  - POST/PUT and getting back the location for new elements
all done through REST+JSON

What I don't understand is how to search by a criteria other than the ID.

Eg.TPerson has a Name and ID.  I can search by ID, but I want to know the search query to select NAME='Erick'?  I don't see that in the REST samples.

Erick

#125 Re: mORMot 1 » Smart Mobile Studio » 2016-07-31 11:58:07

erick wrote:

I put up a quick example of EWB with Mormot working together at http://erickengelke.com/ewb/mormot/mormot.zip
and included the sample's 3kB source code for EWB, though not all the libraries

I will have more information available before September.

Sorry, I changed the link so it wouldn't be confused with a Mormot download

It should be
http://erickengelke.com/ewb/mormot/ewbmormot.zip

#126 Re: mORMot 1 » Smart Mobile Studio » 2016-07-31 03:29:27

I put up a quick example of EWB with Mormot working together at http://erickengelke.com/ewb/mormot/mormot.zip
and included the sample's 3kB source code for EWB, though not all the libraries

I will have more information available before September.

#127 Re: mORMot 1 » Smart Mobile Studio » 2016-07-30 18:28:09

erick wrote:

I have it ALMOST working


Nothing spurs you to make success like saying something stupid.  Mormon is fine, the problem is uniqueness constraint of the data I was posting.  Silly me.

E

#128 Re: mORMot 1 » Smart Mobile Studio » 2016-07-30 18:19:34

I have it ALMOST working, but there is a change that needs to be made in mormot to make it work.
For JSON posts you accept:

   ID : 4
   Name : "Peter"

but embedded in EWB it uses
  "ID" : 4
  "Name" : "Peter"

which is technically valid too, but mormot doesn't seem to like it.
Make EWB not use quotes would break compatibility with systems
that allow embedded spaces.  So I think I will patch mormot to skip
the quotes. 

Wish me luck.

Erick

#129 Re: mORMot 1 » Smart Mobile Studio » 2016-07-30 16:19:57

I got the Get and Delete options working today.  Now I'm working on the POST options.

#130 Re: mORMot 1 » Smart Mobile Studio » 2016-07-30 12:04:45

ab wrote:

Generating cross-platform client code for EWB should not be so much difficult.

Following SMS integration pattern, it is technically feasible.

Generating client wrappers is certainly the way to go with EWB: it would allow safe and efficient access to a mORMot server.

Yes, last night i figured out your protocol on the wire using the browser's network activity pane.
I looked at the javascript example to get started.  Having EWB replace JavaScript is a first goal, then
the more general case will be the next challenge.

Erick

#131 Re: mORMot 1 » Smart Mobile Studio » 2016-07-30 02:34:45

Okay, I've looked back over my mormot work form last year, yeah, definitely mormot on the wire.

EWB lacks native Object Pascal Interfaces in common with Delphi.  I might have to write something to connect it with Mormot.

I'm thinking that rather than use Mormot's shared code of writing interfacing code specifically in EWB.  I mean, the code is so
heavily mixed with {IFDEFs} that I'm afraid of it.

My next step is to see what  mormot looks like on the wire.  I know it's JSON, but what field names it sends and receives
to see what kind of work  I'm going to do.

Erick

#132 Re: mORMot 1 » Smart Mobile Studio » 2016-07-30 00:53:43

erick wrote:
DigDiver wrote:

Does anybody try to use Elevate Web Builder?

> Someone here commented that EWB didn't look as powerful.  There are lots of samples on my web page showing what it can do, including OAuth 2.0 and >interface with almost any JavaScript library.  It's very powerful.

http://erickengelke.com  for samples, including the web page itself.

Erick

#133 Re: mORMot 1 » Smart Mobile Studio » 2016-07-30 00:48:28

After that long introduction, I should say what EWB offers over SOA to help with your understand of my question:

EWB implements RESTful JSON GET and PUT.  The get would be trivial to convert.
The PUT encapsulates Create/Update/Delete of the CRUD model.  I've written code to convert the
request sinto basic SQL, but obviously we don't want clients to have ability to randomly update
create or delete any object they want.  We want business logic.

If I go with the Mormot model, there would be a lot more EWB code to write.  Though presumably I could look at
the SMS Mormot code to get started.

I'm leaning toward running Mormot over the wire and writing libs in EWB to match Mormot.

Erick

#134 Re: mORMot 1 » Smart Mobile Studio » 2016-07-30 00:40:30

DigDiver wrote:

Does anybody try to use Elevate Web Builder?

Hi,

I bought an SmartMobileStudio license a year ago because i wanted to use it for web page development with Mormot, which I chose because of the open database layer.  My projected needed web to database connectivity.

The SMS learning curve felt steep, and so I bought the 3rd party book they advertise, but it was a few years out of date, incomplete, and abandoned.  I was a little annoyed that the sales hype for the book didn't say that.  Also, SMS version 2.2 was promised but not delivered in a long time and they reverted back to 2.1.  I wrote a few apps, but was not enthralled with it.

Someone in a Delphi group enthusiastically suggested Elevate Web Builder EWB 2.04 instead.  So I bought a copy of it and  found it had an active community, new releases every 1/2 year or so, and it felt like Delphi 7 - fast, solid, clean, well documented.  I though it delivered where SMS was still mostly promising.  Maybe in a few months SMS will change, but like everyone, I needed a solution today and to feel the product is actively being improved.

There is now a 200 page book on EWB on Amazon, I know 'cause I wrote it, it's my fourth book.  But I would recommend holding off buying the book because a 300-ish page 2nd edition will be released in about two weeks, it's being proof read by the EWB software author.  Someone here commented that EWB didn't look as powerful.  There are lots of samples on my web page showing what it can do, including OAuth 2.0 and interface with almost any JavaScript library.  It's very powerful.

I didn't write this to sell my book, as evidenced by the fact I just told you not to buy the current book.  I'm just making the point that it has a lot going for it now and that I'm a person who likes to get involved.

What I want to say is EWB includes SOA and obviously serialization and deserialization code from published properties.  But the exchange is currently different than what Mormot expects or uses.   

I haven't yet interfaced it to Mormot.  However that's what I'd like to do next, hopefully with the help of a few mormot-knowedgeable people.

I'm looking for suggestions as to whether to interface with Mormot's interface layer and data exchange, or to use EWB's database model and write a Momot layer which can talk to EWB's SOA api.  The first is more RPC-like, whereas the second would simplify use of things like Grids already available in EWB.

Obviously there are tradeoffs with each model.  Input would be helpful. 

Erick

#135 Re: mORMot 1 » LDAP authentication » 2015-10-09 20:07:18

Okay, I corrected the setuser to SetUser('','') as I'm trying to do NTLM from the local machine as client to the same machine as a server

But still I get the same error:

20151009 19524106  +    TSQLHttpClientWinHTTP(045CF040).Auth
20151009 19524106  +        TSQLHttpClientWinHTTP(045CF040).00E58FA8
20151009 19524106  +    TSQLRestServerDB(046276B0).URI(GET root/Auth?UserName=&data=oXcwdaADCgEBoloEWE5UTE1TU1AAAwAAAAAAAABYAAAAAAAAAFgAAAAAAAAAWAAAAAAAAABYAAAAAAAAAFgAAAAAAAAAWAAAADXCiOIGAbEdAAAAD54u1Ko%2BHDTGDudSwe93qyajEgQQAQAAAA0iwNz5yxUyAAAAAA%3D%3D inlen=0)
20151009 19524106 call      TSQLRestServerDB(046276B0) Auth
20151009 19524640 EXC       EOSError ("System Error.  Code: 87.\r\nThe parameter is incorrect") at 0044A7F6  stack trace API 00BE0641 00BE0675 77209F7F 772088A2 7723D948 000007FEFD25B3DD 00412656 0041268C 0044A7F6 0044A753 00BD745A 00CC4886 00C96E37 00C89F77 00C895B8 00C92C8D 00EAE14F 00E3EEC4 00E4669C 0052FB53 0041320B 770E5A4D 7721B831
20151009 19524646 debug     TSQLRestServerDB(046276B0) TSQLRestRoutingREST.Error: {  "errorCode":500,  "error":  {"EOSError":{"EOSError":"System Error.  Code: 87.\r\nThe parameter is incorrect"}}  }
20151009 19524646 srvr      TSQLRestServerDB(046276B0)   GET root/Auth SOA-Method -> 500 with outlen=116 in 5649099 us
20151009 19524646  -    05.649.132
20151009 19524646 clnt          TSQLHttpClientWinHTTP(045CF040) GET root/Auth?UserName=&data=oXcwdaADCgEBoloEWE5UTE1TU1AAAwAAAAAAAABYAAAAAAAAAFgAAAAAAAAAWAAAAAAAAABYAAAAAAAAAFgAAAAAAAAAWAAAADXCiOIGAbEdAAAAD54u1Ko%2BHDTGDudSwe93qyajEgQQAQAAAA0iwNz5yxUyAAAAAA%3D%3D status=500 state=7
20151009 19524646  -        05.650.276
20151009 19524646 ERROR     TSQLHttpClientWinHTTP(045CF040) GET root/Auth?UserName=&data=oXcwdaADCgEBoloEWE5UTE1TU1AAAwAAAAAAAABYAAAAAAAAAFgAAAAAAAAAWAAAAAAAAABYAAAAAAAAAFgAAAAAAAAAWAAAADXCiOIGAbEdAAAAD54u1Ko%2BHDTGDudSwe93qyajEgQQAQAAAA0iwNz5yxUyAAAAAA%3D%3D returned 500 Internal Server Error with message  {  "errorCode":500,  "error":  {"EOSError":{"EOSError":"System Error.  Code: 87.\r\nThe parameter is incorrect"}}  } stack trace API 00BE30E2 00C72EA8 00C7F69C 00C7EA31 00CC53F2 00CC200C 00C7EC70 00E5E19E 007C48AF 008D4AD1 007C51C6 00B2484B 00A6579E 76FE9BD1 76FE3BFC 76FE3B78 000007FEFBB36205 000007FEFBB36990 000007FEFBB36758 000007FEFBB36990 000007FEFBB36867 76FE9BD1 76FE98DA 00A5F624 00B1AB11 00A5F338 00B1D577 00EE3D2E 770E5A4D 7721B831
20151009 19524646 ret       {  "errorCode":500,  "error":  {"EOSError":{"EOSError":"System Error.  Code: 87.\r\nThe parameter is incorrect"}}  }
20151009 19524646  -    05.650.371
20

#136 Re: mORMot 1 » LDAP authentication » 2015-10-09 15:48:13

Hmmm, I haven't been able to get it to work.

I have nexus\erick2 in my SQLAuthUser database, and when I call client.SetUser( 'nexus\erick2','asdf' )
I see it detects the name as valid because it calls function TSQLRestServerAuthenticationSSPI.Auth

Then it calls function TSQLRestServerAuthenticationSSPI.Auth() twice.  The first time there is no error, but
the second time it raises OS error 87 bad parameters in the function call ServerSSPIAuth()
in the call to AcceptSecurityContext().  I'm sure the userid/password is right, I've tried it a dozen times

I had called  aServer := TSQLRestServerDB.Create(aModel, ':memory:', True);
because I think we are wanting to authenticate users though not passwords from the DB.

FWIW, the socket is on a 127.0.0.1 address.

#137 Re: mORMot 1 » LDAP authentication » 2015-10-08 14:58:36

You'd have to use SSL or a reversable encryption.

#138 mORMot 1 » LDAP authentication » 2015-10-08 13:57:13

erick
Replies: 9

Hi,

Sometimes you want active director domain authentication but you cannot register the service with active directory because that can be a political nightmare on some corporate ADs.  Or you want to test on a device which cannot be registered in the domain, such as on a VPN where I'm currently writing my code.

For the last few hours I've been trying to put my LDAP testing code into the framework.  I'm getting closer, but am a bit intimidated by working 46,000 lines into the mormot.pas code.

I'm trying to patch in my ldap testing code:

const

  SEC_WINNT_AUTH_IDENTITY_ANSI    = $1;

type
  SEC_WINNT_AUTH_IDENTITY_A = packed record
    User: PAnsiChar;
    UserLength: Longint;
    Domain: PAnsiChar;
    DomainLength: Longint;
    Password: PAnsiChar;
    PasswordLength: Longint;
    Flags: Longint;
  end;


function rad_ldap_test( domain : ansistring; server : string; user, pass : ansistring ) : boolean;
var
  h : PLDAP;
  x : ULONG;
  auth : SEC_WINNT_AUTH_IDENTITY_A;

begin
  //Initialization session with Directory Server
  // shoud use ldap_open
  ZeroMemory( @auth, sizeof(auth));
  auth.user := pansichar( user );
  auth.userlength := Length( user );
  auth.Domain := pansichar( domain );
  auth.DomainLength := Length( domain );
  auth.password := pansichar( pass );
  auth.passwordlength := Length( pass );
  auth.flags := SEC_WINNT_AUTH_IDENTITY_ANSI;

  h := ldap_initw(pchar(server), 389);
  if h = Nil then begin
    result := False;
  end else begin

    //Binding with Server
    x := ldap_Connect(h, nil);
    x := ldap_bind_sA(h,Nil,@auth,  LDAP_AUTH_NTLM );
    ldap_unbind( h );

    result := x = 0;
  end;

end;

Does anyone else want to run with it, or you can wait on me.

#139 Re: mORMot 1 » server does not creates tables » 2015-10-07 18:10:33

That works like a charm, thanks.

I'm using both 5.5 ancient, and MariaDB 10.x latest.

Both worked.

#140 Re: mORMot 1 » server does not creates tables » 2015-10-07 15:31:07

I see firedac can support mysql, but I only have Delphi professional version, and we want database stored on a separate server, so firedac is out.

#141 Re: mORMot 1 » server does not creates tables » 2015-10-07 15:15:30

I have a similar problem when using the following code to mysql/mariadb (both fail)

  aModel := TSQLModel.Create([TSQLNotesDB, TSQLStudentsDB], ROOT_NAME);
  try
    pseudoname := 'engugrad';
    MySQL := TOLEDBODBCSQLConnectionProperties.Create(pseudoname, pseudoname,
      '', 'blah', 'blah');
    VirtualTableExternalRegisterAll(aModel, MySQL);

    try
        // create the main mORMot server
        aServer := TSQLRestServerDB.Create(aModel, ':memory:', True);
        try
          // create tables or fields if missing
          aServer.CreateMissingTables;

     
First, CreateMissingTables spits out an exception saying NotesDB table does not exist,
which is true, I'm wanting CreateMissingTables to create it.

The next exception complains from the ODBC driver that CLOB used in trying to create
the table generates an error when I try to use RawUTF8 fields..


If I add index 32 to the RawUTF8, it complains about adding NVARCHAR(32) as being a syntax error.

Problem is, the customer does not want to add Zeos drivers, can SQL over ODBC be tuned to work?

Erick

#142 Re: mORMot 1 » MySQL - ODBC or OLE, neither work for me » 2015-09-21 15:59:10

A collegue of mine figured it out for me, so I'm documenting for those who follow me.

You enter:

  pseudoname := 'mysql.3';
  MySQL := TOLEDBODBCSQLConnectionProperties.Create( pseudoname, pseudoname, '', 'UseridBlah', 'passwordDooHicky');

Then, as long as you have no mismatch between the driver bitness (32 versus 64), it works.

Thanks

#143 mORMot 1 » MySQL - ODBC or OLE, neither work for me » 2015-09-21 15:44:38

erick
Replies: 2

Hi, I'm having trouble connecting to MySQL through either ODBC or OLE.  I've installed the 64 bit drivers for both, and did the ODBC and OLE 'Test Connection' Successfully.

I've compiled SynDBEdit 64 bit and also tried my source code below.  I think I'm just entering a wrong field somewhere, but don't know where.   Examples on this board seem ancient because they generate compiler errors, so I think the syntax may have changed in the last year.

var
  MySQL: TOLEDBODBCSQLConnectionProperties;
  Conn: TSQLDBConnection;
  Query: TSQLDBStatement;
  F: TFileStream;
  password: RawUTF8;

begin

  // Model := CreateSampleModels;

  write('PASSWORD: ');
  readln(password);

//  MySQL := TOLEDBODBCSQLConnectionProperties.Create('mysql.1', 'localhost',
//    'cecs', 'root', StrToUTF8(password));
  MySQL := TOLEDBODBCSQLConnectionProperties.Create('MSDASQL.1','localhost', 'cecs', 'root', StrToUTF8(password));
  try
    Conn := MySQL.NewConnection;
    try
      Query := Conn.NewStatement;
      try
        Query.Execute('select * from employer', True, []);
        // select * from cecs.employer
// It FAILS at Query above with error: Unspecified Error [Microsoft][ODBC Driver Manager] Data Source Name not found and no specififed default driver


        F := TFileStream.Create('result.json', fmCreate);
        try
          Query.FetchAllToJSON(F, True);
        finally
          F.Free;
        end;
      finally
        Query.Free;
      end;
    finally
      Conn.Free;
    end;
  finally
    MySQL.Free;
  end;
  Database.Free;
  Model.Free;

I've tried changing the first argument of ..connectionproperties to 'MySQL ODBC 3.5 Unicode Driver' and other things, but the error never budges.
I've tried creating named user DSNs, named System DSNs, no change.

I've hacked at this for hours, so I'm asking for help.


Any hints on how to get a wor

#144 Re: mORMot 1 » confusion about joined records » 2015-09-18 20:33:00

Okay, I think I've figured it out.  Trying the above and dumping the database confirmed that the entries were in separate tables like I wanted.

#145 mORMot 1 » confusion about joined records » 2015-09-18 20:01:26

erick
Replies: 1

Sorry, some basic questions here.

type
  // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  TSQLparents = class(TSQLRecord)
  private
      fname: RawUTF8;
  published
      property pnt_name: RawUTF8 read fname write fname;
  end;

  // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  TSQLkids = class(TSQLRecord)
  private
      fname: RawUTF8;
      fbirthdate: TDateTime;
      fparent1: TRecordReference;

  published
      property kid_name: RawUTF8 read fname write fname;
      property kid_birthdate: TDateTime read fbirthdate write fbirthdate;
      property kid_parent1: TRecordReference read fparent1 write fparent1;
  end;
...
The database looks fine, with two tables.

I can read it fine with:

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
procedure ShowChildren(Database: TSQLRest);
var
    kid: TSQLkids;
    parent: TSQLparents;
    parentname: string;
    wildcard: RawUTF8;

begin

    writeln('ShowChildren');
    writeln('============');

    wildcard := StringToUTF8('%');

    kid := TSQLkids.Create(Database, 'kid_name LIKE ? ', [wildcard]);
    parent := TSQLparents.Create;
    try
        if kid.id > 0 then
        begin

            // load the parent record... always check if it exists
            if Database.Retrieve(kid.kid_parent1, parent, false) then
                parentname := parent.pnt_name
            else
                parentname := 'N/A';

            writeln('  ID=', kid.id, ' Name= ', kid.kid_name, ' Parent1= ', parentname);

        end;
    finally
        kid.Free;
        parent.Free;
    end;
end;

But I'm forced to do the extra retrieve( kid, kid_parent1, parent, false )  is there a way to inherently
get that information

BTW, I've got a large legacy database to support, I cannot change the structure.

According to the mORMot web pages I can specify joins like:


aProd := TSQLProduct.CreateAndFillPrepareMany(Database,
   'Owner=? and Categories.Dest.Name=? and (Sizes.Dest.Name=? or Sizes.Dest.Name=?)',[],
   ['mark','for boy','small','medium']);
if aProd<>nil then
try
   while aProd.FillOne do
     //  here e.g. aProd.Categories.Dest are instantied (and Categories.Source=aProd)
     writeln(aProd.Name,' ',aProd.Owner,' ',aProd.Categories.Dest.Name,' ',aProd.Sizes.Dest.Name);
   //  you may also use aProd.FillTable to fill a grid, e.g.
   //  (do not forget to set aProd.FillTable.OwnerMustFree := false)
finally
   aProd.Free; //  will also free aProd.Categories/Sizes instances
end;

but what is aProd . Categories . Dest . Name
there is no definition which shows what Categories and Dest are defined as.  I'm assuming

TSQLDest = class( TSQLrecord )
  Name : RawUTF8
end

TSQLCategories = class( TSQLRecord )
  Dest : TSQLdest ;
end

TSQLProduct = class( TSQLRecord )
  Categories : TSQLCategories;
end;

but doesn't that mean it all gets stored in one big TSQLproduct table, not across multiple tables.

Any clues would help.

Erick

#146 Re: mORMot 1 » suggestions » 2015-09-09 17:55:46

Yes, I was looking at exactly that.  My first thought had been to accept msqldump-styled text input, but then I saw syndbexplorer already could learn the database on-the-fly.  I will experiment and get back to the forum when I have something.

Erick

#147 mORMot 1 » suggestions » 2015-09-09 17:39:38

erick
Replies: 2

Hi, I'm new on the forum.  I have a suggestion, but maybe people have already done this.  If not, I'll try my hand.

SQL converter - you take an existing database and build the basic mORMot  TSqlRecrod stuctures
so the programmer doesn't have to. 

I know one would still have to hand sanitize them to make createtime, modifytime, enums etc, but it would
simplify conversion of existing databases, and be particularly helpful to new converts like myself.

Erick

Board footer

Powered by FluxBB