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:
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)?
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)?