473,385 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access remotely by WMI

Hi,

I am trying to list in a web page the processes an the services of a
computer in my workgroup. For my computer I use the windows user and it
works fine. For the remote computer I use admin user and password
entered by text boxes and saved as cookie. The bad part is that I get
"Access denied". The ASPNET user is in Administrators group on my
computer.

ConnectionOptions con = new ConnectionOptions();
if (Request.Cookies["wmiuser"].Value.ToString() != "")
{
con.Username = Request.Cookies["wuser"].Value.ToString();
con.Password = Request.Cookies["wpass"].Value.ToString();
}

ManagementScope ms = new ManagementScope("\\\\" + computer +
"\\root\\cimv2", con);

ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_Service");
ManagementObjectSearcher query = new ManagementObjectSearcher(ms,oq);
ManagementObjectCollection queryColl = query.Get(); //Crash

Please tell me what can be wrong.

Thank you

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #1
4 1454
I would isolate your code as a class. Run the code in an application
and make sure that it works with the results that you expect. Then run
the code in your web application double checking all input values to
make sure these input values are what you expect them to be.

If that still fails then I would look into Impersonation.

Nov 19 '05 #2
The ASPNET account does not have any priviledges on the remote
machine. I'm not sure what you are doing with the cookie, but cookies
won't help gain authorizations on a remote machine, but you could use
the credentials with WindowsIdentity.Impersonate.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 08 Mar 2005 06:52:19 -0800, Dan Pavel
<my**************@yahoo.com> wrote:
Hi,

I am trying to list in a web page the processes an the services of a
computer in my workgroup. For my computer I use the windows user and it
works fine. For the remote computer I use admin user and password
entered by text boxes and saved as cookie. The bad part is that I get
"Access denied". The ASPNET user is in Administrators group on my
computer.

ConnectionOptions con = new ConnectionOptions();
if (Request.Cookies["wmiuser"].Value.ToString() != "")
{
con.Username = Request.Cookies["wuser"].Value.ToString();
con.Password = Request.Cookies["wpass"].Value.ToString();
}

ManagementScope ms = new ManagementScope("\\\\" + computer +
"\\root\\cimv2", con);

ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_Service");
ManagementObjectSearcher query = new ManagementObjectSearcher(ms,oq);
ManagementObjectCollection queryColl = query.Get(); //Crash

Please tell me what can be wrong.

Thank you

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 19 '05 #3
Hi,

for re****@community.nospam:
I already put the code in a win application and it worked fine. I can
access the remote computers and see the running processes and services.

for Scott Allen:
I am using the cookies so the user can enter the admin username and
password in the web app. When I use this username in the win app (see
above) it works ok. When I use it in the web app I get the Access denied
exception when I try to connect to the remote computer.

I would like to use WindowsIdentity.Impersonate but I am not sure I am
understanding it very good. If you have time, please explain me a
little.

Thank you
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #4
http://msdn.microsoft.com/library/de...onatetopic.asp

Sample source code that pretty much does what you need it to do is
available there.

Also Remember to double check the values in your cookie to ensure that
they are what you think they are.

You can look up WindowsIdentity.Impersonate Method in your msdn and
filter the langauge accordingly if you have the MSDN library installed

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bennett Haselton | last post by:
I want to get an ASP.Net hosting account with my ISP, and I'm trying to find out what level of access to the server is requried in order for me to view the server in Server Explorer in Visual...
4
by: Phil | last post by:
Hi all, I need some help to access an SQL db on another machine. I am using VB.NET and remoting to make a client/server connection...although I don't think this is relevant to the question. I...
4
by: kimi | last post by:
Please help me decided the best way to do this... I have a shopping cart web site that stores its data in an SQL server database. The client wants to retrieve daily orders via their access DB...
21
by: Kevin Swanson | last post by:
I'm attempting some remote registry manipulation via C#. I've written a test app to simply grab a specified key from a specified hive on a specified machine. The call to OpenSubKey is throwing...
0
by: Marc Melancon | last post by:
I have a situation where accessing perfmon counters remotely does not display the same list of Performance Objects remotely as it does when doing it from the host of SQL Server. From the host of...
1
by: ThunderMusic | last post by:
Hi, I have many classes a user may need to call methods on my webservice. Some classes are "published" and some are not... I mean, when we do a Web reference from another project, we don't have...
14
by: ApexData | last post by:
I am considering building some distributable commercial applications. For about a year now, I have been using Access2000. This was my first venture into object oriented database development. ...
1
by: remote | last post by:
when i try to access my data access page remotely with i can't get my data. Why this happens?
0
by: boomertoo55 | last post by:
Trying to exec DTS task involving load of MS Access table to SQL Server 2000 table using Data Pump task via remote exec of xp_cmdshell command of dtsrun. That is, on client, connect to database...
3
by: Sonasang | last post by:
Hi , I am develping a web page with MYSQL as backend.... I have installed MYSQL and MYSQL connector to access the datas remotely... But i am getting the error when i try to access the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.