#1 2014-08-25 15:33:28

Sabbiolina
Member
Registered: 2014-05-20
Posts: 120

[Interface based Services] Internal data

Hi AB.

how do I know who is making a call within an interface member?

Let me explain:

TServiceCalculator.Add function (n1, n2: integer): integer;
begin

   // HERE!. Log ip, username of caller


   result: = n1 + n2;
end;

Thanks

Offline

#2 2014-08-25 19:26:43

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 129

Re: [Interface based Services] Internal data

AFAIK you can do this

var
  context: TServiceRunningContext;
  user: Integer;
Begin
  context := CurrentServiceContext;
  user  := context.Request.SessionUser;  
End;

Regards

Offline

#3 2014-08-25 19:53:17

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

Re: [Interface based Services] Internal data

Indeed.

Or you can use directly the ServiceContext threadvar, but it would be a less efficient than a local copy.

For instance:

var
  context: PServiceRunningContext;
  RemoteIP: RawUTF8;
begin
  context := @ServiceContext;
  RemoteIP := FindIniNameValue(pointer(context.Request.Call.InHead),'REMOTEIP: ');
end;

See the documentation about ServiceContext threadvar, and in the SAD pdf.

Also note that a lot of information is already logged, including authenticated session, and IP of the caller.

I've just added Remote IP and Connection ID fields so that you can write now:

var context: PServiceRunningContext;
begin
  context := @ServiceContext;
  writeln(context.Request.SessionRemoteIP);
end;

See http://synopse.info/fossil/info/e1cdc8d438

Offline

#4 2014-08-26 07:10:58

Sabbiolina
Member
Registered: 2014-05-20
Posts: 120

Re: [Interface based Services] Internal data

You are magic

Offline

Board footer

Powered by FluxBB