<identity impersonate="true"> userName="Domain/Username" password="password" /></identity>
private void StartService(string serviceName, int timeoutMilliseconds) { Configuration objConfigFile; //getting an instance of the configuration file objConfigFile = WebConfigurationManager.OpenWebConfiguration( HttpContext.Current.Request.ApplicationPath); //getting an instance of the "identity" section of the cofiguration file IdentitySection objIdentitySection = (IdentitySection)objConfigFile.GetSection("system.web/identity"); if (objIdentitySection != null) { string username = objIdentitySection.UserName; string password = objIdentitySection.Password; bool impersonate = objIdentitySection.Impersonate; //Configuration currentConfiguration = objIdentitySection.C.CurrentConfiguration; //Obviously you won't be doing this. The lines below are just for testing purpose ServiceController service = new ServiceController(serviceName); try { TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds); service.Start(); service.WaitForStatus(ServiceControllerStatus.Running, timeout); } catch(Exception ex) { throw (ex); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)