IIS Reset thru Web access denied in Window 2003

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default IIS Reset thru Web access denied in Window 2003

    I tried to reset IIS thru Web using the following code

    ProcessStartInfo si = new ProcessStartInfo("cmd.exe");
    // Redirect both streams so we can write/read them.
    si.RedirectStandardInput = true;
    si.RedirectStandardOutput = true;
    si.UseShellExecute = false;
    // Start the procses.
    Process p = Process.Start(si);
    p.StandardInput.WriteLine("iisreset","/restart");
    p.StandardInput.WriteLine("exit");
    // Read all the output generated from it.
    string output = p.StandardOutput.ReadToEnd();

    StreamWriter writer = new StreamWriter(alertLog, true, Encoding.UTF8);
    writer.WriteLine(DateTime.Now + ": \"" + output);
    writer.Close();

    The code work in Windows 2000 server, the output is
    Attempting stop...
    Internet services successfully stopped
    Attempting start...
    Internet services successfully restarted

    but when I run the code in Windows 2003 Enterprise Edition, the iisreset
    don't work and I get
    1/12/2005 3:33:24 PM: "Microsoft Windows [Version 5.2.3790]
    (C) Copyright 1985-2003 Microsoft Corp.

    c:\windows\system32\inetsrv>iisreset

    Access denied, you must be an administrator of the remote computer to use
    this

    command. Either have your account added to the administrator local group of

    the remote computer or to the domain administrator global group.


    c:\windows\system32\inetsrv>exit

    Do anyone know how to solve this?


    Royston Guest

  2. Similar Questions and Discussions

    1. Ext Manager - how do you reset window location?
      quite a silly one, but very annoying: had twin monitors, now got one only. when I open the extension manager, it opens off the viewable screen...
    2. Window 2003 Environment issue - Component Access error
      Hi all, An application which is working perfectly in Windows 2000 Server is now installed in Window 2003 Server. A component (VB Component)...
    3. ACCESS DENIED between 2003 and NT 4.0
      I have two domains, one is Server 2003 (called "ALPHA") with active directory, the other is NT 4.0 (Called "BETA"). I have set up a two way trust...
    4. How to reset activation data to reativate a Windows 2003 Server
      Hi How to reset activation data to reativate a Windows 2003 Server ? (The system says that activation is corrupted at logon and needs to...
    5. Access denied when creating Access application object
      In an ASP file I am running the following in VBScript in order to extract data from an Access 2002 MDB file which is physically located in the...
  3. #2

    Default Re: IIS Reset thru Web access denied in Window 2003

    Are you sure the current ASP.NET worker process is running as an
    administrator? That seems like the most likely cause of the problem.

    Under 2003, they are usually run under NETWORK SERVICE.

    Joe K.

    "Royston" <royston@earth9.com> wrote in message
    news:Ob$ZWZR%23EHA.2876@TK2MSFTNGP12.phx.gbl...
    >I tried to reset IIS thru Web using the following code
    >
    > ProcessStartInfo si = new ProcessStartInfo("cmd.exe");
    > // Redirect both streams so we can write/read them.
    > si.RedirectStandardInput = true;
    > si.RedirectStandardOutput = true;
    > si.UseShellExecute = false;
    > // Start the procses.
    > Process p = Process.Start(si);
    > p.StandardInput.WriteLine("iisreset","/restart");
    > p.StandardInput.WriteLine("exit");
    > // Read all the output generated from it.
    > string output = p.StandardOutput.ReadToEnd();
    >
    > StreamWriter writer = new StreamWriter(alertLog, true, Encoding.UTF8);
    > writer.WriteLine(DateTime.Now + ": \"" + output);
    > writer.Close();
    >
    > The code work in Windows 2000 server, the output is
    > Attempting stop...
    > Internet services successfully stopped
    > Attempting start...
    > Internet services successfully restarted
    >
    > but when I run the code in Windows 2003 Enterprise Edition, the iisreset
    > don't work and I get
    > 1/12/2005 3:33:24 PM: "Microsoft Windows [Version 5.2.3790]
    > (C) Copyright 1985-2003 Microsoft Corp.
    >
    > c:\windows\system32\inetsrv>iisreset
    >
    > Access denied, you must be an administrator of the remote computer to use
    > this
    >
    > command. Either have your account added to the administrator local group
    > of
    >
    > the remote computer or to the domain administrator global group.
    >
    >
    > c:\windows\system32\inetsrv>exit
    >
    > Do anyone know how to solve this?
    >
    >

    Joe Kaplan \(MVP - ADSI\) Guest

  4. #3

    Default Re: IIS Reset thru Web access denied in Window 2003

    I have found that this method will not work as when System.Diagnostics start
    a new process, the process always inherits the security context of the
    parent process. Even if the ASP.NET thread invoking the Start method is
    impersonating a client, the Process still starts with the ASP.NET worker
    process credentials

    I have worked around this using DuplicateTokenEx & CreateProcessAsUser win32
    api (refer to [url]http://odetocode.com/Blogs/scott/archive/2004/10/28/602.aspx[/url]).
    However, this solution work in window 2003 but fail in window 2000 (I get
    1314 error when running this on a Window 2000 machine)

    "Royston" <royston@earth9.com> wrote in message
    news:Ob$ZWZR%23EHA.2876@TK2MSFTNGP12.phx.gbl...
    > I tried to reset IIS thru Web using the following code
    >
    > ProcessStartInfo si = new ProcessStartInfo("cmd.exe");
    > // Redirect both streams so we can write/read them.
    > si.RedirectStandardInput = true;
    > si.RedirectStandardOutput = true;
    > si.UseShellExecute = false;
    > // Start the procses.
    > Process p = Process.Start(si);
    > p.StandardInput.WriteLine("iisreset","/restart");
    > p.StandardInput.WriteLine("exit");
    > // Read all the output generated from it.
    > string output = p.StandardOutput.ReadToEnd();
    >
    > StreamWriter writer = new StreamWriter(alertLog, true, Encoding.UTF8);
    > writer.WriteLine(DateTime.Now + ": \"" + output);
    > writer.Close();
    >
    > The code work in Windows 2000 server, the output is
    > Attempting stop...
    > Internet services successfully stopped
    > Attempting start...
    > Internet services successfully restarted
    >
    > but when I run the code in Windows 2003 Enterprise Edition, the iisreset
    > don't work and I get
    > 1/12/2005 3:33:24 PM: "Microsoft Windows [Version 5.2.3790]
    > (C) Copyright 1985-2003 Microsoft Corp.
    >
    > c:\windows\system32\inetsrv>iisreset
    >
    > Access denied, you must be an administrator of the remote computer to use
    > this
    >
    > command. Either have your account added to the administrator local group
    of
    >
    > the remote computer or to the domain administrator global group.
    >
    >
    > c:\windows\system32\inetsrv>exit
    >
    > Do anyone know how to solve this?
    >
    >

    Royston Guest

  5. #4

    Default Re: IIS Reset thru Web access denied in Window 2003

    Right, the 1314 is something like "a needed privilege is not held by the
    client". This is because you need to have the SE_TCB_NAME privilege to call
    LogonUser or CreateProcessAsUser under Windows 2000, and generally that is
    only given to the SYSTEM account.

    This is a very common issue on Windows 2000.

    Joe K.

    "Royston" <royston@earth9.com> wrote in message
    news:ut6RIBj%23EHA.3840@tk2msftngp13.phx.gbl...
    >I have found that this method will not work as when System.Diagnostics
    >start
    > a new process, the process always inherits the security context of the
    > parent process. Even if the ASP.NET thread invoking the Start method is
    > impersonating a client, the Process still starts with the ASP.NET worker
    > process credentials
    >
    > I have worked around this using DuplicateTokenEx & CreateProcessAsUser
    > win32
    > api (refer to
    > [url]http://odetocode.com/Blogs/scott/archive/2004/10/28/602.aspx[/url]).
    > However, this solution work in window 2003 but fail in window 2000 (I get
    > 1314 error when running this on a Window 2000 machine)
    >
    > "Royston" <royston@earth9.com> wrote in message
    > news:Ob$ZWZR%23EHA.2876@TK2MSFTNGP12.phx.gbl...
    >> I tried to reset IIS thru Web using the following code
    >>
    >> ProcessStartInfo si = new ProcessStartInfo("cmd.exe");
    >> // Redirect both streams so we can write/read them.
    >> si.RedirectStandardInput = true;
    >> si.RedirectStandardOutput = true;
    >> si.UseShellExecute = false;
    >> // Start the procses.
    >> Process p = Process.Start(si);
    >> p.StandardInput.WriteLine("iisreset","/restart");
    >> p.StandardInput.WriteLine("exit");
    >> // Read all the output generated from it.
    >> string output = p.StandardOutput.ReadToEnd();
    >>
    >> StreamWriter writer = new StreamWriter(alertLog, true, Encoding.UTF8);
    >> writer.WriteLine(DateTime.Now + ": \"" + output);
    >> writer.Close();
    >>
    >> The code work in Windows 2000 server, the output is
    >> Attempting stop...
    >> Internet services successfully stopped
    >> Attempting start...
    >> Internet services successfully restarted
    >>
    >> but when I run the code in Windows 2003 Enterprise Edition, the iisreset
    >> don't work and I get
    >> 1/12/2005 3:33:24 PM: "Microsoft Windows [Version 5.2.3790]
    >> (C) Copyright 1985-2003 Microsoft Corp.
    >>
    >> c:\windows\system32\inetsrv>iisreset
    >>
    >> Access denied, you must be an administrator of the remote computer to use
    >> this
    >>
    >> command. Either have your account added to the administrator local group
    > of
    >>
    >> the remote computer or to the domain administrator global group.
    >>
    >>
    >> c:\windows\system32\inetsrv>exit
    >>
    >> Do anyone know how to solve this?
    >>
    >>
    >
    >

    Joe Kaplan \(MVP - ADSI\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139