Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 68459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:25:11+00:00 2026-05-10T19:25:11+00:00

I’ve got a website that has windows authentication enable on it. From a page

  • 0

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.

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.

My question is:


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?


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…..

Here’s some of the code I’ve got:

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;         } 

My exception comes from the second line in the try block. Here’s the error:

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()

Thanks for the help/info

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:25:12+00:00Added an answer on May 10, 2026 at 7:25 pm

    Note: This doesn’t address enumerating services as a different user, but given the broader description of what you’re doing, I think it’s a good answer.

    I think you can simplify this a lot, and possibly avoid part of the security problem, if you go directly to the service of interest. Instead of calling GetServices, try this:

    string machineName = ConfigurationManager.AppSettings['ServiceMachineName']; string serviceName = ConfigurationManager.AppSettings['ServiceName']; ServiceController service = new ServiceController( serviceName, machineName ); return service.Status; 

    This connects directly to the service of interest and bypasses the enumeration/search step. Therefore, it doesn’t require the caller to have the SC_MANAGER_ENUMERATE_SERVICE right on the Service Control Manager (SCM), which remote users do not have by default. It does still require SC_MANAGER_CONNECT, but according to MSDN that should be granted to remote authenticated users.

    Once you have found the service of interest, you’ll still need to be able to stop and start it, which your remote users probably don’t have rights to do. However, it’s possible to modify the security descriptor (DACL) on individual services, which would let you grant your remote users access to stop and start the service without requiring them to be local admins. This is done via the SetNamedSecurityInfo API function. The access rights you need to grant are SERVICE_START and SERVICE_STOP. Depending on exactly which groups these users belong to, you might also need to grant them GENERIC_READ. All of these rights are described in MSDN.

    Here is some C++ code that would perform this setup, assuming the users of interest are in the ‘Remote Service Controllers’ group (which you would create) and the service name is ‘my-service-name’. Note that if you wanted to grant access to a well-known group such as Users (not necessarily a good idea) rather than a group you created, you need to change TRUSTEE_IS_GROUP to TRUSTEE_IS_WELL_KNOWN_GROUP.

    The code has no error checking, which you would want to add. All three functions that can fail (Get/SetNamedSecurityInfo and SetEntriesInAcl) return 0 to indicate success.

    Another Note: You can also set a service’s security descriptor using the SC tool, which can be found under %WINDIR%\System32, but that doesn’t involve any programming.

    #include 'windows.h' #include 'accctrl.h' #include 'aclapi.h'  int main() {     char serviceName[] = 'my-service-name';     char userGroup[] = 'Remote Service Controllers';      // retrieve the security info     PACL pDacl = NULL;     PSECURITY_DESCRIPTOR pDescriptor = NULL;     GetNamedSecurityInfo( serviceName, SE_SERVICE,         DACL_SECURITY_INFORMATION, NULL, NULL,         &pDacl, NULL, &pDescriptor );      // add an entry to allow the users to start and stop the service     EXPLICIT_ACCESS access;     ZeroMemory( &access, sizeof(access) );     access.grfAccessMode = GRANT_ACCESS;     access.grfAccessPermissions = SERVICE_START | SERVICE_STOP;     access.Trustee.TrusteeForm = TRUSTEE_IS_NAME;     access.Trustee.TrusteeType = TRUSTEE_IS_GROUP;     access.Trustee.ptstrName = userGroup;     PACL pNewDacl;     SetEntriesInAcl( 1, &access, pDacl, &pNewDacl );      // write the changes back to the service     SetNamedSecurityInfo( serviceName, SE_SERVICE,         DACL_SECURITY_INFORMATION, NULL, NULL,         pNewDacl, NULL );      LocalFree( pNewDacl );     LocalFree( pDescriptor ); } 

    This could also be done from C# using P/Invoke, but that’s a bit more work.

    If you still specifically want to be able to enumerate services as these users, you need to grant them the SC_MANAGER_ENUMERATE_SERVICE right on the SCM. Unfortunately, according to MSDN, the SCM’s security can only be modified on Windows Server 2003 sp1 or later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here is an example (including creating an event) for ASP.NET… May 11, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer You might consider looking at Isolated Storage which is a… May 11, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer You cannot prevent this from happening. However, you can enable… May 11, 2026 at 11:34 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.