Remoting - Requesting client details

Nickels

Member
Joined
May 8, 2003
Messages
7
Location
England
I have a client/server database app and have wrapped up all of the database access into a class which will run on the server. I have a console app which makes this class available to client machines via remoting.

For analysis purposes, I am looking to record the machine name and current user of the requesting client every time a function is called, e.g. "Username Bill on machine name PC001 called the function GetData()". To test this out I have added the following code to the constructor function of database access class:

Code:
        Get the current identity and put it into an identity object.
        Dim MyIdentity As WindowsIdentity = WindowsIdentity.GetCurrent()

        Put the previous identity into a principal object.
        Dim MyPrincipal As New WindowsPrincipal(MyIdentity)

        Get the current environment data
        Dim MyEnvironment As System.Environment

I can then use these objects to ascertain the machine name/current user. However, this always returns the details about the local machine (i.e. the server that the object is running on) rather than the details of the remote client calling the function.

Is there a (relatively) easy way to get these client details from within the database access class on the server, or do I have to put the code into the client app and then pass the login details through to the server to be recorded (which I dont particularly want to do as it will change the signature of all of my functions and cause lots of extra work)?
 
Do you instantiate the Class once a client starts or do you instantiate it several times?
 
The clients instantiate the object whenever they need to use it and then destroy it straight after:

Code:
Dim clsDatabase As clsDataAccess = CType(Activator.GetObject(GetType(clsDataAccess), strRemotingURL), clsDataAccess)

...uses the object...

clsDatabase = Nothing

It doesnt matter too much now as I have rewritten the app so that the user details are (rather clumsily) passed from the client to the server, but if you have any idea how to do it properly it is something that would come in handy in a few of my apps.
 
Back
Top