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
Michael Nemtsev - 07 Jun 2007 08:49 GMT
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 - 07 Jun 2007 10:44 GMT
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
> Hello LamSoft,
>
[quoted text clipped - 12 lines]
> L> System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal
> L>
Michael Nemtsev - 07 Jun 2007 11:06 GMT
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" <nemtsev@msn.com> wrote in message
L> news:a279a63a3f64188c977110d6a0eae@msnews.microsoft.com...
L>
>> Hello LamSoft,
>>
[quoted text clipped - 12 lines]
>> L> System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal
>> L>