Access Denied to use WMI getting remote resource

Discussion in 'ASP .Net' started by LamSoft, Jun 7, 2007.

  1. LamSoft

    LamSoft Guest

    I have the access denied on my ASP.NET C# program while deploy my project from my PC (WinXP) to Server 2003
    The program works fine on my PC but get access denied on Server 2003.

    However the program works fine on Windows Server 2003 while trying to use WMI to get resource from the itsself computer, just has the problem while remoting to other computer.

    I did put the permission of all security to "Everyone" on "Windows Managment and Instrustmentation" in Component Service, or even put the ASP.NET account is as a group of Administrators and no help, did I do anything wrong? Thank you.

    Here is the stack trace:
    [UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))]
    System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) +0
    System.Management.ManagementScope.InitializeGuts(Object o) +784
    System.Management.ManagementScope.Initialize() +216
    System.Management.ManagementScope.Connect() +5
    _Default.showUserList(String password, String server) +293
    _Default.btnSubmit_Click(Object sender, EventArgs e) +58
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102



    Here is some of the code in "Default.aspx"

    Protected Sub showUserList(ByVal password As String, ByVal server As String)
    If server = "" Then
    MS = New ManagementScope("\\.\root\cimv2")
    MS.Connect()
    objQuery = New System.Management.ObjectQuery("Select Name from Win32_UserAccount")
    Else
    conn.Username = "administrator"
    conn.Password = password
    MS = New ManagementScope("\\" & server & "\root\cimv2", conn)
    MS.Connect()
    objQuery = New System.Management.ObjectQuery("Select Name from Win32_UserAccount")
    End If
    .........
    End Sub
     
    LamSoft, Jun 7, 2007
    #1
    1. Advertising

  2. Michael Nemtsev, Jun 7, 2007
    #2
    1. Advertising

  3. LamSoft

    LamSoft Guest

    I changed the processModel back to machine from system. system runs as
    localsystem with high permissions while machine runs as low privilege user
    account.

    Sorry, I don't understand that guy meaning, what is the processModel and
    where he changed the permission?
    Thanks

    "Michael Nemtsev" <> wrote in message
    news:...
    > Hello LamSoft,
    >
    > Maybe this helps
    > http://dotnetjunkies.com/Forums/ShowPost.aspx?PostID=11159
    > guys discussed the same problem
    >
    > ---
    > WBR, Michael Nemtsev [.NET/C# MVP]. My blog:
    > http://spaces.live.com/laflour
    > Team blog: http://devkids.blogspot.com/
    >
    > "The greatest danger for most of us is not that our aim is too high and we
    > miss it, but that it is too low and we reach it" (c) Michelangelo
    >
    > L> System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal
    > L>
    >
     
    LamSoft, Jun 7, 2007
    #3
  4. Hello LamSoft,

    MSDN will help u http://msdn2.microsoft.com/en-us/library/7w2sway1.aspx

    ---
    WBR, Michael Nemtsev [.NET/C# MVP].
    My blog: http://spaces.live.com/laflour
    Team blog: http://devkids.blogspot.com/

    "The greatest danger for most of us is not that our aim is too high and we
    miss it, but that it is too low and we reach it" (c) Michelangelo

    L> I changed the processModel back to machine from system. system runs
    L> as localsystem with high permissions while machine runs as low
    L> privilege user account.
    L>
    L> Sorry, I don't understand that guy meaning, what is the processModel
    L> and
    L> where he changed the permission?
    L> Thanks
    L> "Michael Nemtsev" <> wrote in message
    L> news:...
    L>
    >> Hello LamSoft,
    >>
    >> Maybe this helps
    >> http://dotnetjunkies.com/Forums/ShowPost.aspx?PostID=11159 guys
    >> discussed the same problem
    >>
    >> ---
    >> WBR, Michael Nemtsev [.NET/C# MVP]. My blog:
    >> http://spaces.live.com/laflour
    >> Team blog: http://devkids.blogspot.com/
    >> "The greatest danger for most of us is not that our aim is too high
    >> and we miss it, but that it is too low and we reach it" (c)
    >> Michelangelo
    >>
    >> L> System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal
    >> L>
    >>
     
    Michael Nemtsev, Jun 7, 2007
    #4
    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. Roy Osherove

    Access Denied for WMI/ADSI over ASP.Net

    Roy Osherove, Sep 9, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    7,198
    s.becker
    Sep 14, 2003
  2. KQ
    Replies:
    1
    Views:
    463
  3. Heinrich Moser
    Replies:
    1
    Views:
    474
    Heinrich Moser
    Mar 27, 2008
  4. davidj411
    Replies:
    7
    Views:
    3,346
    Tim Golden
    Oct 8, 2009
  5. J M
    Replies:
    1
    Views:
    382
    A. Sinan Unur
    Apr 11, 2005
Loading...

Share This Page