If you mean, enable/disable and query token privileges, your only option is using PInvoke (or managed extensions for C++), none of
the WIN32 security API's are currently accessible through the FCL classes.
As for your question on shutdown and shutdown privileges, you can use the Management classes (WMI wrapper) to shutdown, reboot a
system.
Following is a sample using System.Management and WMI:
using System.Management;
....
// Query the WMI namespace for Win32_OperatingSystem making sure only the current instance is returned
SelectQuery query = new SelectQuery("select name from Win32_OperatingSystem where primary=true");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach(ManagementObject os in searcher.Get())
{
// Enable SeShutdownPrivilege, the calling process must have SeShutdownPrivilege
os.Scope.Options.EnablePrivileges = true;
ManagementBaseObject outParams = os.InvokeMethod("Shutdown", null, null);
}
Willy.
Quote:
> Is there a namespace where you can query/change the privileges of an
> application? As I need to give my application privileges to shutdown the
> system and wondered if there was a way of doing this in .NET rather than
> reverting to the windows API.
> Adam