简体   繁体   中英

Windows service with User account Login

I'm having a windows service with User account as 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? 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. 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"]; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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