简体   繁体   English

Windows服务(使用用户帐户登录)

[英]Windows service with User account Login

I'm having a windows service with User account as Logon. 我有一个Windows服务,用户帐户为Logon。 1. Is there any way i can retrieve it from AD instead of promoting the user to enter the user name and password while installing service? 1.在安装服务时,有什么方法可以从AD检索而不是促使用户输入用户名和密码? I cannot use Local system since i need to validate the user with database inside the service. 我无法使用本地系统,因为我需要使用服务中的数据库验证用户。 2. Another problem is while password change, windows service password is not updating, i need to go and change it manually. 2.另一个问题是更改密码时,Windows服务密码未更新,我需要手动进行更改。 Is there any remedy? 有什么补救办法吗?

I have handled the situation by using Local system it self. 我已经通过使用本地系统自行处理了这种情况。 In order to get the Logged user name i'm using, 为了获取我正在使用的日志用户名,

ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT UserName FROM Win32_ComputerSystem");
ManagementObjectCollection collection = searcher.Get();
currentUser = (string)collection.Cast<ManagementBaseObject>().First()["UserName"]; 

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

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