Mark Levison

Musings on No Touch Deployment, .NET development and photography

<September 2008>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011


Navigation

Other

Blogroll

Subscriptions

Post Categories



Tuesday, November 30, 2004 - Posts

Undocumented Permission Surprises

I'm trying to tighten our permission demands, so that we only demand the permissions that we absolutely need.  Looking at the documentation for StandardPrinterController, no mention of permissions is made in the requirements.  Being the suspicious type I fired up Reflector and made quite the set of discoveries.

All of the OnStartXXX() and OnEndXXX() methods call Check.Security():

    private void CheckSecurity(PrintDocument document)
    {
          if (document.PrinterSettings.PrintDialogDisplayed)
          {
                IntSecurity.SafePrinting.Demand();
          }
          else if (document.PrinterSettings.IsDefaultPrinter)
          {
                IntSecurity.DefaultPrinting.Demand();
          }
          else
          {
                IntSecurity.AllPrinting.Demand();
          }
    }

    I think this is testing how the document was created (PrintDialogDisplayed isn't documented either).  My guess is, if the user created this PrintDocument via the standard Print dialog then only safe printing is required.  Otherwise stronger demands are made.

    The next surpise all the methods demand Unmanaged Code Permission.  The final indignity both the OnStartXXX() methods demand AllPrinting permission.

    The moral of this story, MS hasn't done a very good job of documenting the security requirements of many of the classes in the BCL.  When you have a sneaking suspicion that an operation requires a permission that isn't documented, you might just be right.  Fire up reflector and take a closer look.

    posted Tuesday, November 30, 2004 12:37 PM by mlevison with 0 Comments




    Powered by Dot Net Junkies, by Telligent Systems