File owner of the file created by windows service

833 Views Asked by At

I am developing a java application which entails that the owner of the files that are created by my application is different other than the one who will be using the application. I am contemplating installing this application as a windows service. This windows service will be installed as that user (for e.g. AppAdmin) and then when ever my java application that is running as a windows service creates a file the owner of the file will be AppAdmin.

The question is - Does this make sense ? Please advice. I am mostly a mac / unix user. Do not know much about windows.

1

There are 1 best solutions below

1
On

When a Windows process is running, it has an associated user. Typically that would be the logged in interactive user. When a process creates a file, the file owner is deemed to be the user associated with the process that creates the file.

Services are a little different. There is no logged in interactive user. However, in the service control panel, for each service, you specify the log on user for the service. That user will be the owner of any files created by the service.

Processes are able to impersonate other users. When they do so, they owner of any created files would be the impersonated user. However, that's a more advanced topic and I'm reasonably confident that you are not using impersonation. That being said, you could use impersonation to achieve your goal and so avoid the need for a separate service. But judging from your question that might well have undesirable security implications.