ASPX : ACCESS denied when start/stop windows services

Discussion in 'ASP .Net' started by SenthilVel, Aug 12, 2004.

  1. SenthilVel

    SenthilVel Guest

    Hi All

    i do need to control my windows services using aspx pages.

    I used the System.ServiceProcess.ServiceController namespace ....
    this is working fine when i run my code in a windows application .

    But when i use the code to start /Stop the service in a aspx page i get an
    error like:

    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.ComponentModel.Win32Exception: Access is denied


    so what must i do in settings or in permission levels so that i can run the
    service start/stop code in ASPX pages??

    can any one explain what to do in detail..

    ,,,,
    Senthil
    SenthilVel, Aug 12, 2004
    #1
    1. Advertising

  2. You can use impersonation to run ASP.NET under an account that has
    permission to interact with windows services.
    Here's more info:
    http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconaspnetimpersonation.asp

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "SenthilVel" <> wrote in message
    news:...
    > Hi All
    >
    > i do need to control my windows services using aspx pages.
    >
    > I used the System.ServiceProcess.ServiceController namespace ....
    > this is working fine when i run my code in a windows application .
    >
    > But when i use the code to start /Stop the service in a aspx page i get an
    > error like:
    >
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.ComponentModel.Win32Exception: Access is denied
    >
    >
    > so what must i do in settings or in permission levels so that i can run
    > the
    > service start/stop code in ASPX pages??
    >
    > can any one explain what to do in detail..
    >
    > ,,,,
    > Senthil
    >
    >
    Steve C. Orr [MVP, MCSD], Aug 12, 2004
    #2
    1. Advertising

  3. SenthilVel

    SenthilVel Guest

    Hi Steve
    i added the impersonate="true" in my config files.
    but still i am not able to access the services from aspx pages.
    it says " permission denied".
    what to do ?

    ,,,,
    Senthil



    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:...
    > You can use impersonation to run ASP.NET under an account that has
    > permission to interact with windows services.
    > Here's more info:
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
    l/cpconaspnetimpersonation.asp
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://Steve.Orr.net
    >
    >
    > "SenthilVel" <> wrote in message
    > news:...
    > > Hi All
    > >
    > > i do need to control my windows services using aspx pages.
    > >
    > > I used the System.ServiceProcess.ServiceController namespace ....
    > > this is working fine when i run my code in a windows application .
    > >
    > > But when i use the code to start /Stop the service in a aspx page i get

    an
    > > error like:
    > >
    > > Description: An unhandled exception occurred during the execution of the
    > > current web request. Please review the stack trace for more information
    > > about the error and where it originated in the code.
    > >
    > > Exception Details: System.ComponentModel.Win32Exception: Access is

    denied
    > >
    > >
    > > so what must i do in settings or in permission levels so that i can run
    > > the
    > > service start/stop code in ASPX pages??
    > >
    > > can any one explain what to do in detail..
    > >
    > > ,,,,
    > > Senthil
    > >
    > >

    >
    >
    SenthilVel, Aug 12, 2004
    #3
  4. Give it a specific username and password to use.
    For testing, give it your username and password so it will run with your
    security privileges.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "SenthilVel" <> wrote in message
    news:%...
    > Hi Steve
    > i added the impersonate="true" in my config files.
    > but still i am not able to access the services from aspx pages.
    > it says " permission denied".
    > what to do ?
    >
    > ,,,,
    > Senthil
    >
    >
    >
    > "Steve C. Orr [MVP, MCSD]" <> wrote in message
    > news:...
    >> You can use impersonation to run ASP.NET under an account that has
    >> permission to interact with windows services.
    >> Here's more info:
    >>

    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
    > l/cpconaspnetimpersonation.asp
    >>
    >> --
    >> I hope this helps,
    >> Steve C. Orr, MCSD, MVP
    >> http://Steve.Orr.net
    >>
    >>
    >> "SenthilVel" <> wrote in message
    >> news:...
    >> > Hi All
    >> >
    >> > i do need to control my windows services using aspx pages.
    >> >
    >> > I used the System.ServiceProcess.ServiceController namespace ....
    >> > this is working fine when i run my code in a windows application .
    >> >
    >> > But when i use the code to start /Stop the service in a aspx page i get

    > an
    >> > error like:
    >> >
    >> > Description: An unhandled exception occurred during the execution of
    >> > the
    >> > current web request. Please review the stack trace for more information
    >> > about the error and where it originated in the code.
    >> >
    >> > Exception Details: System.ComponentModel.Win32Exception: Access is

    > denied
    >> >
    >> >
    >> > so what must i do in settings or in permission levels so that i can run
    >> > the
    >> > service start/stop code in ASPX pages??
    >> >
    >> > can any one explain what to do in detail..
    >> >
    >> > ,,,,
    >> > Senthil
    >> >
    >> >

    >>
    >>

    >
    >
    Steve C. Orr [MVP, MCSD], Aug 12, 2004
    #4
  5. SenthilVel

    megha

    Joined:
    Apr 5, 2008
    Messages:
    1
    Same problem

    I m having same problem. i m trying to access windows service from my web application. but it is giving access denied error.
    please let me know if u find any solution.

    Thnks in advance.
    megha, Apr 5, 2008
    #5
  6. SenthilVel

    Neuron Upheaval

    Joined:
    Jan 16, 2009
    Messages:
    1
    Location:
    Brazil
    This worked for me

    Hi!

    I have a web application which connects to a Windows service running in another computer, and some information about this service is retrieved using System.ServiceProcess.ServiceController interface.

    Whenever I opened the web application, it used to hang with the same "Access denied error" as described above.

    The workaround was to include the following node to the <system.web> node located inside the web application's Web.config file:

    <identity impersonate="true" userName="userName" password="password" />

    where userName and password are the logon attributes of an user with enough security rights on the service-running computer.
    Last edited: Jan 16, 2009
    Neuron Upheaval, Jan 16, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. marius

    Stop and start services

    marius, Aug 29, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    3,188
    Tommy
    Aug 29, 2003
  2. Replies:
    4
    Views:
    5,283
    Steve C. Orr [MVP, MCSD]
    Jun 15, 2004
  3. Anup
    Replies:
    1
    Views:
    2,774
    Mark Rae
    May 9, 2006
  4. ra294
    Replies:
    0
    Views:
    342
    ra294
    Oct 16, 2006
  5. ra294

    Setting permission to start and stop services

    ra294, Oct 16, 2006, in forum: ASP .Net Security
    Replies:
    0
    Views:
    142
    ra294
    Oct 16, 2006
Loading...

Share This Page