Hi,
Is it possible to access a file (read/write/delete/move...) using different credentials then the one the logged in user?
Hi,
Is it possible to access a file (read/write/delete/move...) using different credentials then the one the logged in user?
What's relevant is not the logged in user but the user under which the process is running - these are not necessarily the same.
However, running a process under a different user ID is very OS-specific, and there is no Java API for it. Besides, it would have to be done when the JVM starts up, as I do not think any OS allows a process to switch its user ID.
Not directly from the JVM, no.
But under Windows, you could do exec()
with a RunAs
command, and under Unix/Linux/OS X you could do exec()
with sudo
. Though you may end up getting prompted for the password.