Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Server Sessions
Wed, Aug 23 2006 12:17 PMPermanent Link

Michael Mount
Hi,

I am trying to figure out how to add/get a piece of information to my server sessions.  Currently the list view shows the logged in user name, IP Address,
and connection status.  What I'd like to add is a piece of information identifying the connected PC.  Essentially, the system is set up so all users connect
to the database using one of a few different login names.  We have hundreds of users and rather than keep adding users to the database we thought it
would be simpler to just verify the user in code after connecting.

The client application connects using a shared database username/password then queries a table with a user specific name and password to check for
rights and permission to connect (kind of).  If the user is allowed to connect we update a field in their record with that timestamp so we can always see
when the last time they logged into the sytem was.  What I'd like to do is:

a) Also write their IP address when I update the timestamp.
b) Show their user specific name is the sessions list.

I figure the place to do this is either in a custom server function, or a beforeupdate trigger but can't for the life of me figure out how to tell which session
is responsible for the request.  Is there any way to tell?

I am using v4.16.  Thanks,

Mike
Wed, Aug 23 2006 3:15 PMPermanent Link

"Jose Eduardo Helminsky"
Michael

You can use the following function to retrieve the machine name passing IP
address.

function IPAddrToName(IPAddr: string): string;
var SockAddrIn: TSockAddrIn;
   HostEnt: PHostEnt;
   WSAData: TWSAData;
begin
    WSAStartup($101, WSAData);
    SockAddrIn.sin_addr.s_addr := inet_addr(PChar(IPAddr));
    HostEnt := gethostbyaddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET);
    if HostEnt <> nil then begin
       Result := StrPas(Hostent^.h_name)
    end else begin
       Result := '';
    end;
    WSACleanup;
end;

Eduardo

Wed, Aug 23 2006 3:34 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< The client application connects using a shared database username/password
then queries a table with a user specific name and password to check for
rights and permission to connect (kind of).  If the user is allowed to
connect we update a field in their record with that timestamp so we can
always see when the last time they logged into the sytem was. >>

As an aside, the upcoming ElevateDB does all of this for you, including
logging the login time as well as the IP address, computer name, process ID
and other important information.

<< What I'd like to do is:

a) Also write their IP address when I update the timestamp.
b) Show their user specific name is the sessions list.

I figure the place to do this is either in a custom server function, or a
beforeupdate trigger but can't for the life of me figure out how to tell
which session is responsible for the request.  Is there any way to tell? >>

What you want to do is modify the dbsrvr.dpr and change the OnServerConnect,
OnServerLogin, etc. events to record the desired information along with
displaying the desired information in the list view.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Aug 23 2006 3:59 PMPermanent Link

Michael Mount
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

What you want to do is modify the dbsrvr.dpr and change the OnServerConnect,
OnServerLogin, etc. events to record the desired information along with
displaying the desired information in the list view.


Tim,

I agree that would be simplest but at those times I have no additional information from the client yet (do I)?  Is there something I can set on the client
that will pass this data onto those events?

Mike
Image