473,397 Members | 2,068 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,397 software developers and data experts.

Using Windows Authentication with WMI and ASP.NET

I'm building a test web application that, when run, will launch calc.exe on
my computer. It seems to work as it appears in Windows Task Manager;
however, the process doesn't actually pop up because it runs as ASPNET rather
than the user I want. When having to run ASP.NET as another user (e.g. when
doing AD queries), I was able to use IIS Windows Authentication and
impersonation. These are still enabled, but they don't seem to be helping.
Here is the method I'm using:

Sub test()

Dim objWMIService, objProcess
Dim strShell, objProgram, strComputer, strExe

strExe = "calc.exe"
' Input Box to get name of machine to run the process
strComputer = "RIC0001994"

' Connect to WMI
objWMIService = GetObject("winmgmts://" _
& strComputer & "/root/cimv2")
' Obtain the Win32_Process class of object.
objProcess = objWMIService.Get("Win32_Process")
objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe

'Execute the program now at the command line.
strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)

End Sub

Thanks.
Jul 1 '08 #1
3 3556
just guessing ...

- did you forget to turn off anonymous access for this page ?

- running as ASPNET in itself would not inhibit user interface
- sounds like it is inheriting the unattended process attribute from
asp.net

- i have successfully used win32/pinvoke to temporarily impersonate
another user - that might help you
Jul 1 '08 #2
this will never work. iis and asp.net are services and do not have
access to the desktop. thus any application they start will also not
have access to desktop and can not create any windows. asp.net should
only spawn console apps.

-- bruce (sqlwork.com)

Brian Nicholson wrote:
I'm building a test web application that, when run, will launch calc.exe on
my computer. It seems to work as it appears in Windows Task Manager;
however, the process doesn't actually pop up because it runs as ASPNET rather
than the user I want. When having to run ASP.NET as another user (e.g. when
doing AD queries), I was able to use IIS Windows Authentication and
impersonation. These are still enabled, but they don't seem to be helping.
Here is the method I'm using:

Sub test()

Dim objWMIService, objProcess
Dim strShell, objProgram, strComputer, strExe

strExe = "calc.exe"
' Input Box to get name of machine to run the process
strComputer = "RIC0001994"

' Connect to WMI
objWMIService = GetObject("winmgmts://" _
& strComputer & "/root/cimv2")
' Obtain the Win32_Process class of object.
objProcess = objWMIService.Get("Win32_Process")
objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe

'Execute the program now at the command line.
strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)

End Sub

Thanks.
Jul 2 '08 #3
All right -- well thanks for the help. I don't actually need to do that in
my application; I was just assuming that launching it under my account rather
than ASPNET would then open the window as a result; that wasn't my actual
goal. What I am really trying to do is figure out a way to start a process
using WMI under different user credentials. ASP.NET impersonation doesn't
seem to affect launching separate processes, so what's the best way to go
about doing this?

In the end, my final goal is something like this: an admin user will go to
the page and click a button that will connect to WMI and launch a batch file
(located in a shared folder) on a specified computer. This batch file will
then perform a task on the computer it runs on. You can see the problem --
as of now, the batch file is launched with the ASP.NET user which does not
have necessary permissions to perform the intended tasks. Ideally, the same
Windows Authentication used for ASP.NET apps could be used to launch this
batch file so it would have the permissions to perform the necessary
functions.

Thank you.

"bruce barker" wrote:
this will never work. iis and asp.net are services and do not have
access to the desktop. thus any application they start will also not
have access to desktop and can not create any windows. asp.net should
only spawn console apps.

-- bruce (sqlwork.com)

Brian Nicholson wrote:
I'm building a test web application that, when run, will launch calc.exe on
my computer. It seems to work as it appears in Windows Task Manager;
however, the process doesn't actually pop up because it runs as ASPNET rather
than the user I want. When having to run ASP.NET as another user (e.g. when
doing AD queries), I was able to use IIS Windows Authentication and
impersonation. These are still enabled, but they don't seem to be helping.
Here is the method I'm using:

Sub test()

Dim objWMIService, objProcess
Dim strShell, objProgram, strComputer, strExe

strExe = "calc.exe"
' Input Box to get name of machine to run the process
strComputer = "RIC0001994"

' Connect to WMI
objWMIService = GetObject("winmgmts://" _
& strComputer & "/root/cimv2")
' Obtain the Win32_Process class of object.
objProcess = objWMIService.Get("Win32_Process")
objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe

'Execute the program now at the command line.
strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)

End Sub

Thanks.
Jul 2 '08 #4

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

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
5
by: John | last post by:
I am creating an application that I would like to have the user type in their User ID, password and domain, and it do Windows Authentication to verify they are a valid user. Can someone provide...
2
by: YRao | last post by:
I am going to create intranet application using Windows Authentication using C# asp.net I am having following problem: 1 setting windows Authentication, it will validate for all users, user...
4
by: Dave | last post by:
Hi, Is there anyway to mimic forms authentication's loginUrl and RedirectFromLoginPage functionality using Windows authentication? We are developing intranet sites using basic authentication...
2
by: Maziar Aflatoun | last post by:
Hi guys, I'm using Windows authentication to connect to SQL Server 2000. On my computer the connection is fine. Now if I move it to a remote server, how to I hard code my Username/Password in...
2
by: thechaosengine | last post by:
Hi eveyone, If anyone could advise on the following I would be truly greatful: I have a fairly standard set up. An IIS 5.1 website set up with anonymous access allowed in all areas of the site...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
1
by: Andy | last post by:
Hi, I was wondering if someone could advise on if the following is possible. I have one website that is available to the public using Forms authentication and the Membership class, it...
3
by: Jay-nospam | last post by:
Hi there, I am having trouble getting an ASP.NET web application to connect to another computer and passing the proper credentials and I hope someone can help me. I have a stand-alone Windows...
3
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web...
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: 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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.