title: .Net 2.0 ServiceController.GetServices()
body: <p>I've got a website that has windows authentication enable on it. From a page in the website, the users have the ability to start a service that does some stuff with the database.</p>
  
  <p>It works fine for me to start the service because I'm a local admin on the server. But I just had a user test it and they can't get the service started.</p>
  
  <p>My question is:</p>
  
  <hr>
  
  <p><strong>Does anyone know of a way to get a list of services on a specified computer by name using a different windows account than the one they are currently logged in with?</strong></p>
  
  <hr>
  
  <p>I really don't want to add all the users that need to start the service into a windows group and set them all to a local admin on my IIS server.....</p>
  
  <p>Here's some of the code I've got:</p>
  
  <pre><code>public static ServiceControllerStatus FindService()
          {
              ServiceControllerStatus status = ServiceControllerStatus.Stopped;
  
              try
              {
                  string machineName = ConfigurationManager.AppSettings["ServiceMachineName"];
                  ServiceController[] services = ServiceController.GetServices(machineName);
                  string serviceName = ConfigurationManager.AppSettings["ServiceName"].ToLower();
  
                  foreach (ServiceController service in services)
                  {
                      if (service.ServiceName.ToLower() == serviceName)
                      {
                          status = service.Status;
                          break;
                      }
                  }
              }
              catch(Exception ex)
              {
                  status = ServiceControllerStatus.Stopped;
                  SaveError(ex, "Utilities - FindService()");
              }
  
              return status;
          }
  </code></pre>
  
  <p>My exception comes from the second line in the try block. Here's the error:</p>
  
  <blockquote>
    <p>System.InvalidOperationException:
    Cannot open Service Control Manager on
    computer 'server.domain.com'. This
    operation might require other
    privileges. --->
    System.ComponentModel.Win32Exception:
    Access is denied --- End of inner
    exception stack trace --- at
    System.ServiceProcess.ServiceController.GetDataBaseHandleWithAccess(String
    machineName, Int32
    serviceControlManaqerAccess) at
    System.ServiceProcess.ServiceController.GetServicesOfType(String
    machineName, Int32 serviceType) at
    TelemarketingWebSite.Utilities.StartService()</p>
  </blockquote>
  
  <p>Thanks for the help/info</p>