I need to get the username of the current active logged on user.
I have tried
And that does work however this is where it becomes a little tricky.
The java app will run as a service using the NetworkService service account and when using the above code it returns 'NetworkService'.
What I want is to get the java code to return the current logged on user, not the user who is running the java app.
Is there a way of achieving this?