简体   繁体   English

如何将新服务帐户引入现有C#Windows服务

[英]How to introduce a new service account to an existing C# windows service

I have a windows service that is currently running as LocalSystem. 我有一个Windows服务,当前正在作为LocalSystem运行。 At this point it cannot acess a network drive that it needs to. 在这一点上,它无法访问所需的网络驱动器。 (I've been substituting local drive for testing). (我一直在用本地驱动器进行测试)。

Now I have a newly created service account for me that has been given permisions to the shared drive. 现在,我为我创建了一个新的服务帐户,该帐户已分配给共享驱动器。

I am not sure how to "cut over" my C# app to use this new service account going forward. 我不确定如何“切入”我的C#应用​​程序以继续使用此新服务帐户。

Once I do, will this new account appear under the 'Log On As' column when viewing the service from the service panel? 完成后,从服务面板查看服务时,此新帐户会出现在“登录身份”列下吗?

thanks for any assistance. 感谢您的协助。

  1. Windows Key + R Windows键+ R
  2. Type services.msc 键入services.msc
  3. Right click service and select "Properties" 右键单击服务,然后选择“属性”
  4. Select "Log On" tab on the dialog 在对话框中选择“登录”选项卡
  5. Select "This account" radio button 选择“此帐户”单选按钮
  6. Enter account information for your newly created domain account (eg, mydomain\\myaccount). 输入您新创建的域帐户的帐户信息(例如,mydomain \\ myaccount)。

The account that you enter must have "Log on as a service" privileges per the Local Security Policy (%windir%\\system32\\secpol.msc /s); 根据本地安全策略(%windir%\\ system32 \\ secpol.msc / s),您输入的帐户必须具有“作为服务登录”特权。 windows usually prompts you automatically when performing the above steps. Windows通常会在执行上述步骤时自动提示您。

Also, don't forget the basics. 另外,请不要忘记基础知识。 The account must have at least read file system permissions to your service executable. 该帐户必须至少具有对服务可执行文件的读取文件系统权限。

And yes, this account will appear in the "Log On As" column when this is set correctly. 是的,正确设置此帐户后,该帐户将显示在“登录身份”列中。

Finally, it's been a few iterations of windows / active directory versions since I've done this kind of thing. 最后,这是Windows / Active Directory版本的几次迭代,因为我已经做了这种事情。 It's possible that there are additional delegation-type security settings that may need to be set in active directory / on the local machine to allow the service running as the domain account access a drive on a remote share. 可能需要在本地计算机上的活动目录/中设置其他委托类型的安全设置,以允许在域帐户访问远程共享上的驱动器时运行的服务。 Perhaps some tweaks to the local firewall might need to be made as well. 也许还需要对本地防火墙进行一些调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM