The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Undocumented Permission Surprises

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mark Levison

Posts: 877
Nickname: mlevison
Registered: Jan, 2003

Mark Levison an agile software developer who writes Notes from a tool user.
Undocumented Permission Surprises Posted: Nov 30, 2004 10:30 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Mark Levison.
Original Post: Undocumented Permission Surprises
Feed Title: Mark Levison
Feed URL: /WebLog/error.aspx?aspxerrorpath=/WebLog/mlevison/Rss.aspx
Feed Description: Musings on No Touch Deployment, .NET development and photography
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Mark Levison
Latest Posts From Mark Levison

Advertisement

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.


    This Blog Hosted On: http://www.DotNetJunkies.com/

    Read: Undocumented Permission Surprises

    Topic: Geek Dinner was juust fine... Previous Topic   Next Topic Topic: How to be more productive

    Sponsored Links



    Google
      Web Artima.com   

    Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use