Solved

WMI Privileges

Posted on 2004-04-29
7
951 Views
Last Modified: 2013-12-03
Hi,
my domain users have policies to run logon logoff vbs script. I must denied logon for some users.
This is the code:
......
For Each os In GetObject("winmgmts:{impersonationLevel=impersonate,(shutdown,remoteshutdown)}!//" +        
                objNet.Computername).InstancesOf("Win32_OperatingSystem")
         retCode = os.Win32Shutdown(4, 0)
Next
......
objNet.Computername is the PC to shutdown.

When the administrator runs the code, the pc shutdown normally. Any other user get this error message:

Code 80041062, privilege not available. (iswbemobject)

The error is on the line retCode = os.Win32Shutdown(4, 0)

With DCOMCNFG everything seems OK for the application Windows Management Instrumentation.

Any suggestion?

Thank you
0
Comment
Question by:Meronic
  • 3
  • 2
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 10950328
Are you sure that the 'Shutdown computer' privilege is granted to these users?
0
 

Author Comment

by:Meronic
ID: 10950640
I'm sorry; not shutdown computer but logoff; Users does not have privilege to shutdown computer and I don't want to assign them the right.


os.Win32Shutdown(4, 0)
4 means logoff, right??


Thanks
0
 
LVL 86

Expert Comment

by:jkr
ID: 10950799
See http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32shutdown_method_in_class_win32_operatingsystem.asp ("Win32Shutdown Method of the Win32_OperatingSystem Class") - it clearly states that "On computer systems running Windows® NT/Windows 2000, the calling process must have the SE_SHUTDOWN_NAME privilege", regardless of what the parameters are...
0
 

Author Comment

by:Meronic
ID: 10951478
How can I verify the process privilege?
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 10951971
I am not too familiar with WMI, but http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_privilegesstatus.asp ("Win32_PrivilegesStatus") should help.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question