Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread How to transfer request.userName and request.password to module
Fri, Dec 21 2018 8:30 AMPermanent Link

Iztok Lajovic (1)

I cannot get proper request.userName and request.password  in EWB module. Every attempt to authenticate the user fails with error 'Authentication failed'.

a) In calling EWB program I have following code:

 with serverRequest do begin
   RequestHeaders.Clear;
   RequestHeaders.Values['Content-Type']:='text/plain';
   params.clear;
   Params.Values['user']:='Administrator';
   Params.Values['password']:='EDBDefault';
   URL:='/modules/ewbMyModule';
   Execute;
 end;


b) In 'ewbMyModule' I have in the function DatabaseAdapterAuthenticateUser following statement:

 Authenticated := AnsiSameText(RequestUserName,'Administrator') and
                            (RequestPassword='EDBDefault');

c) Later, in function EWBModuleExecute I prepare the message to get information about requestUser and requestPassword that were passed to EWB module:

   Request.ResponseHeaders.Clear;
   Request.ResponseHeaders.Add('Cache-Control: no-cache');
   Request.ResponseHeaders.Add('Content-Type: text/plain');
   Request.SendContent(Request.RequestUser + ' ' + request.RequestPassword);

d) In calling program in function ServerRequestComplete I get the following response in responseContent.text:
- if I put the code c) in the program with no statement statement 'if AuthenticateUser(Request) ...' then I get values 'Administrator EDBDefault' meaning that both fields requestUser and requestPassword have appropriate values
- if I include statement  'if AuthenticateUser(Request) ...' then I get error 'Authentication failed'.

Question is: where and how can I pass the values for RequestUserName and RequestPassword required in in code b) from corresponding values request.requestUser and resquest.request.password to pass user authentication without error?

Thank you
Iztok Lajovic
Sun, Dec 23 2018 6:18 AMPermanent Link

Iztok Lajovic (1)

>Question is: where and how can I pass the values for RequestUserName and RequestPassword required in in >code b) from corresponding values request.requestUser and resquest.request.password to pass user >authentication without error?

I found workaround for this problem: if I put following explicit code for the session (although both attributes are defined in session parameters):

   sekcija.LoginUser := Request.RequestUser;
   sekcija.LoginPassword := request.RequestPassword;

then I can pass failing connection of the session.

I found next obstacle in the same way: although the attribute 'session.localConfigPath' is defined in sessions' parameters I have to put following additional code:

  session.LocalConfigPath := 'c:\..\EDB';

If I don't repeat this information then I get the error like 'session.LocalConfigPath is empty'

What I have to do to avoid this unexpected behavior?

Iztok Lajovic
Mon, Dec 31 2018 11:22 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Iztok,

<< I found workaround for this problem: if I put following explicit code for the session (although both attributes are defined in session parameters): >>

How are you setting up the ElevateDB engine parameters ?  If you're trying to access a database using a local session, then there are certain ElevateDB engine parameters that need to be set up *once* in the web server module in the initialization section in order to have things work correctly with multiple threads, etc.

The databasemodule.dpr example web server module that is included with EWB shows how to do this for ElevateDB (at the bottom of the page):

https://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Example_Applications

You probably don't want to use an in-memory configuration, but the general idea is the same.

Tim Young
Elevate Software
www.elevatesoft.com
Image