WMI Permissions through IIS

Dan Naab DanN at SonicFoundry.com
Wed Jun 20 13:29:15 EDT 2001


I'm not certain to what extent this is a Python question as opposed to a WMI
(Windows Management Intrumentation) or Microsoft IIS question, but I haven't
had much luck finding information elsewhere so maybe someone here can help.

I've written a Python script to manage (create, remove, and view) Windows
Task Scheduler jobs.  All the functionality works great when run on the
console but the call to create a new task fails when run as a cgi script
through IIS.

I'm using Microsoft's WBEM system, WMI, which has the Win32_ScheduledJob
class.  I can enumerate existing jobs and create new ones through this
interface.  Here's a piece of code that is failing through IIS:

________________________________________________________________________
    # create new Win32_ScheduledJob object
    job =
GetObject("WinMgmts:{impersonationLevel=impersonate}!root/cimv2:Win32_Schedu
ledJob");

    # get parameters object for method call to Create()
    methCreate = job.Methods_('Create');
    params = methCreate.InParameters.SpawnInstance_();
    params.Properties_( 'Command' ).Value = cmdLine;
    params.Properties_( 'StartTime' ).Value = time;
    params.Properties_( 'RunRepeatedly' ).Value = 1;
    params.Properties_( 'DaysOfWeek' ).Value = daysOfWeek;

    # execute the Create() method with params
    retVal = job.ExecMethod_( 'Create', params ).returnValue;
________________________________________________________________________

On web execution, retVal == 2 or 22 irregardless of the input values.  The
WMI docs do not define any error codes for the Create() function (0
indicates success).  The obvious implication is that permissions are set
incorrectly on the server or I am requesting the wrong permissions or
impersonationLevel from WMI.  In the interest of finding out _what_
permission is set too low, I have changed practically everything from the
root WMI rights to access rights on the local hard drive, to different
impersonationLevels, to various other WMI permissions which can be requested
through GetObject... all to no avail.  Of course there's also the
possibility that there are some Python-specific settings that are set
incorrectly.

Any ideas what I'm missing?

Thanks,
Dan




More information about the Python-list mailing list