Using the proper service account to move files from one machine to another (windows service)

J

Jim in Arizona

I made up a service that will move files from a folder on the machine that
the service is running to a share on another machine. I use a try/catch
incase an error is thrown and write that error to the application log.

I have tried running the service first under LocalSystem and when that
didn't work, under NetworkService. In each case, I'm getting an access
denied (Access to the path is Denied).

I tried different accounts with little luck until I used NETWORK (not
NETWORK SERVICE). Once I used that account, the file move was able to take
place. I don't know what kind of security risk this entails.

Can someone tell me the right way to go about this; which security principal
to use, what accounts to use for the Share and Security ACLs? Is there a
better way to go about this?

TIA,
Jim
 
J

Jim in Arizona

Digging deeper into the net, I see that I can set the Account property of
the ServiceProccessInstaller1 to User. I've read that the account username
and password can be set for this (such as a domain user account) but I can't
find any examples of how this is done.

Does anyone know how to do this?

Thanks,
Jim
 
J

Jim in Arizona

Jim in Arizona said:
Digging deeper into the net, I see that I can set the Account property of
the ServiceProccessInstaller1 to User. I've read that the account username
and password can be set for this (such as a domain user account) but I
can't find any examples of how this is done.

Does anyone know how to do this?

Thanks,
Jim

I was amazed to see that no one had an answer for this. After further
investigative work along with trial and error, I found that setting the
username/password was really easy. I made a domain account, set permissions
on the folders on both ends, made a security template to give the account
permission over a specific service I wanted my code to start/stop, and
everything then worked.

When adding a Project Installer for the service, you can then view the code
of the ProjectInstaller.vb file and add the appropriate credentials there.

Imports System.ComponentModel
Imports System.Configuration.Install

Public Class ProjectInstaller

Public Sub New()
MyBase.New()

'This call is required by the Component Designer.
InitializeComponent()

'Add initialization code after the call to InitializeComponent
ServiceProcessInstaller1.Account =
ServiceProcess.ServiceAccount.User
ServiceProcessInstaller1.Username = "domainname\accountname"
ServiceProcessInstaller1.Password = "passwrd"

End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top