Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Using Windows Authentication with WMI and ASP.NET

Reply
Thread Tools

Using Windows Authentication with WMI and ASP.NET

 
 
Brian Nicholson
Guest
Posts: n/a
 
      07-01-2008
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.
 
Reply With Quote
 
 
 
 
John Rivers
Guest
Posts: n/a
 
      07-01-2008
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
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      07-02-2008
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.

 
Reply With Quote
 
Brian Nicholson
Guest
Posts: n/a
 
      07-02-2008
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.

>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best practices for using forms authentication and security in a hosted env (was: Re: Using a Forms authentication in a shared hosting environment) JEFF ASP .Net 1 11-12-2007 07:00 PM
using wmi and security... micky ASP .Net 0 12-06-2005 07:03 AM
Creating DNS Reverse Lookup zones, and PTR records using VBScript and WMI Rahul Apte ASP General 0 04-27-2004 11:43 AM
Using WMI and ASP to obtain remote client info Lain ASP General 0 01-23-2004 05:31 AM
Tip: Windows internals using wmi Colin Brown Python 8 10-08-2003 08:15 AM



Advertisments