Privilege class RRS feed

  • Question

  • We need to be able to enable/disable privilages in our app. There is article on MSDN ( that descripbed how to write Privilege class, but it is not more than System.Security.AccessControl.Privilege class from mscorlib.dll Why is System.Security.AccessControl.Privilege internal? What is the best way to overcome this limitation (using aforementioned article, writing your own Privilege class that is forwarding call to System.Security.AccessControl.Privilege using reflection, etc.)?

    Tuesday, January 24, 2012 7:04 PM

All replies

  • So what else do you want except for " System.Security.AccessControl.Privilege " class?

    If the System.Security.AccessControl.Privilege can bot satisfy your requirement, you need to find some particular Win32 APIs for your target.

    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Thursday, January 26, 2012 9:11 AM
  • Paul,

    I do not need more than System.Security.AccessControl.Privilege class provides. But this class is internal.

    Thursday, January 26, 2012 4:28 PM
  • So it is by design. It is internal because it is not necessary use the class by ourselves. Other methods or classes in System.Security assembly can access the internal class and interactive with developers.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 30, 2012 8:49 AM
  • I nee to initiate a system shutdown. There is no managed API to do this. So I have to call InitiateSystemShutdownEx, which requires SeShutdownPrivilege to be enabled. How do I do this?
    Monday, January 30, 2012 3:57 PM
  • Actually, we can use managed code to shut down the system, please use code below:

    System.Diagnostics.Process.Start("Shutdown", "-s -t 10");

    I think this can help you.

    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 31, 2012 3:57 AM
  • It is like calling Process.Start("dir") to get directory listing.

    I think you are missing my point. There are cases when you need to enable a privilege that managed code does not have an equivalent. What if you are writing a backup software and need SeBackupPrivilege? Or debugger with a need for SeDebugPrivilege? Or if you are doing something crazy and actually need SeTcbPrivilege?

    Tuesday, January 31, 2012 5:39 AM