Re: Safe Printing

From: Shel Blauman [MSFT] (sheldonb_at_online.microsoft.com)
Date: 01/09/04


Date: Fri, 9 Jan 2004 10:59:48 -0800

The only way I can get an Internet permission set equivalent to work is to
up the printing permissions to all. Doesn't work with safe.

-- 
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
news:%238UyrJt1DHA.4060@TK2MSFTNGP11.phx.gbl...
> I am still having difficulty in getting this to work.  I have attached an
> updated sample project with what I am trying to accomplish.
>
> The project will be run over the Internet Zone with the default security
> settings which have limited UIPermissions and SafePrinting.  The
permissions
> that I have enforced on the project are listed below this message.  One
> change that I had to do was to move the UIPermission from Minimal to
> Optional in order for the application to run over the Internet Zone.
>
> If somebody is able to get printing working with the permissions I have
> described, could you please provide some sample code as to how it was
done?
> I am not sure if I am just missing something small or if I am completely
> off-base with this.  Having the print dialog is not a requirement for this
> if it violates the default security settings for the Internet Zone.
>
> Permissions on the Assembly:
> ------------------------------
> minimal permission set:
> <PermissionSet class="System.Security.PermissionSet"
>                version="1">
>    <IPermission class="System.Security.Permissions.SecurityPermission,
> mscorlib, Version=1.0.5000.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089"
>                 version="1"
>                 Flags="Execution"/>
>    <IPermission class="System.Drawing.Printing.PrintingPermission,
> System.Drawing, Version=1.0.5000.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a"
>                 version="1"
>                 Level="SafePrinting"/>
> </PermissionSet>
>
> optional permission set:
> <PermissionSet class="System.Security.PermissionSet"
>                version="1">
>    <IPermission class="System.Security.Permissions.UIPermission, mscorlib,
> Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>                 version="1"
>                 Unrestricted="true"/>
> </PermissionSet>
>
> refused permission set:
>   Not specified
>
>
>
>
>
> "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
> news:OBrh5tk1DHA.556@TK2MSFTNGP11.phx.gbl...
> > Let me admend this, you'll also need safe printing.  Just to display the
> > dialog box you're going to need unrestricted UIPermission, then to
perform
> > the printing you'll need the safe printing permission.  Was able to run
> your
> > app to completion with safe printing permission.  You may not need all
the
> > other permissions I came up with, you might try experimenting.
> >
> > Shel
> >
> > -- 
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> > Use of included script samples are subject to the terms specified at
> > http://www.microsoft.com/info/cpyright.htm
> >
> >
> > "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com> wrote in message
> > news:e2A%23%23fk1DHA.1760@TK2MSFTNGP10.phx.gbl...
> > > Here's the permission requirements I get when I check your
application:
> > >
> > > <IPermission class="System.Security.Permissions.EnvironmentPermission,
> > > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > > PublicKeyToken=b77a5c561934e089"
> > >              version="1"
> > >              Unrestricted="true"/>
> > > <IPermission class="System.Security.Permissions.FileIOPermission,
> > mscorlib,
> > > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > >              version="1"
> > >              Unrestricted="true"/>
> > > <IPermission class="System.Security.Permissions.SecurityPermission,
> > > mscorlib, Version=1.0.5000.0, Culture=neutral,
> > > PublicKeyToken=b77a5c561934e089"
> > >              version="1"
> > >              Flags="UnmanagedCode, ControlEvidence"/>
> > > <IPermission class="System.Security.Permissions.UIPermission,
mscorlib,
> > > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > >              version="1"
> > >              Unrestricted="true"/>
> > > <IPermission class="System.Net.WebPermission, System,
> Version=1.0.5000.0,
> > > Culture=neutral, PublicKeyToken=b77a5c561934e089"
> > >              version="1"
> > >              Unrestricted="true"/>
> > >
> > >
> >
>
============================================================================
> > > ====
> > > Shel
> > > -- 
> > > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
> > > Use of included script samples are subject to the terms specified at
> > > http://www.microsoft.com/info/cpyright.htm
> > >
> > >
> > > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > > news:%23mFecRk1DHA.4032@tk2msftngp13.phx.gbl...
> > > > The code in question is as follows:
> > > >
> > > > With dlgPrintSettings
> > > >
> > > > If Not (.ShowDialog() = DialogResult.Cancel) Then
> > > >
> > > > Try
> > > >
> > > > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> > > >
> > > > .Document.Print()
> > > >
> > > > TextBox1.AppendText("Print Successful")
> > > >
> > > > Catch ex As Exception
> > > >
> > > > Debug.WriteLine(ex.ToString)
> > > >
> > > > 'MsgBox(ex.ToString)
> > > >
> > > > End Try
> > > >
> > > > End If
> > > >
> > > > End With
> > > >
> > > >
> > > >
> > > > The security exception is thrown within the following line:
> > > >
> > > > If Not (.ShowDialog() = DialogResult.Cancel) Then
> > > >
> > > > after you click the PRINT button. The line below it never gets
called:
> > > >
> > > > TextBox1.AppendText("Printing ..." & ControlChars.CrLf)
> > > >
> > > >
> > > >
> > > > Thanks,
> > > > Jody
> > > >
> > > > "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> > > > news:urXMp2j1DHA.2972@TK2MSFTNGP09.phx.gbl...
> > > > > Jody,
> > > > >
> > > > >         I can not access your sample code.  Could you please post
a
> > link
> > > > to
> > > > > or email me your code.
> > > > >
> > > > > Ken
> > > > > ----------------
> > > > > "Jody Gelowitz" <jody@mail.visualstatement.com> wrote in message
> > > > > news:uz28bFj1DHA.2388@TK2MSFTNGP09.phx.gbl...
> > > > > >I am trying to find the definition of "Safe Printing" and cannot
> find
> > > out
> > > > > > exactly what this entitles.  The reason is that I am trying to
> print
> > > > > > contents from a single textbox to no avail using the PrintDialog
> > > control
> > > > > > under a security setting with only SafePrinting allowed.
> > > > > >
> > > > > > I have attached a sample project that I am using to try to
> > accomplish
> > > > > > this.
> > > > > > The print dialog appears, but when I press the Print button, I
get
> > an
> > > > > > exception (at the end of this message).  Any ideas how I can
make
> > this
> > > > > > work?
> > > > > >
> > > > > > Thanks,
> > > > > > Jody
> > > > > >
> > > > > >
> > > > > > System.Security.SecurityException: Request for the permission of
> > type
> > > > > > System.Drawing.Printing.PrintingPermission, System.Drawing,
> > > > > > Version=1.0.5000.0, Culture=neutral,
> PublicKeyToken=b03f5f7f11d50a3a
> > > > > > failed.
> > > > > >   at
> > > System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet
> > > > > > grantedSet, PermissionSet deniedSet, CodeAccessPermission
demand,
> > > > > > PermissionToken permToken)
> > > > > >   at
> System.Security.CodeAccessSecurityEngine.Check(PermissionToken
> > > > > > permToken, CodeAccessPermission demand, StackCrawlMark&
stackMark,
> > > Int32
> > > > > > checkFrames, Int32 unrestrictedOverride)
> > > > > >   at
> > > System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission
> > > > > > cap, StackCrawlMark& stackMark)
> > > > > >   at System.Security.CodeAccessPermission.Demand()
> > > > > >   at System.Drawing.Printing.PrinterSettings.SetHdevmode(IntPtr
> > > > hdevmode)
> > > > > >   at
> System.Windows.Forms.PrintDialog.UpdatePrinterSettings(PRINTDLG
> > > > data,
> > > > > > PrinterSettings settings, PageSettings pageSettings)
> > > > > >   at System.Windows.Forms.PrintDialog.RunDialog(IntPtr
hwndOwner)
> > > > > >   at System.Windows.Forms.CommonDialog.ShowDialog()
> > > > > >   at PrintTest.Form1.Button1_Click(Object sender, EventArgs e)
> > > > > >   at System.Windows.Forms.Control.OnClick(EventArgs e)
> > > > > >   at System.Windows.Forms.Button.OnClick(EventArgs e)
> > > > > >   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs
mevent)
> > > > > >   at System.Windows.Forms.Control.WmMouseUp(Message& m,
> MouseButtons
> > > > > > button, Int32 clicks)
> > > > > >   at System.Windows.Forms.Control.WndProc(Message& m)
> > > > > >   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
> > > > > >   at System.Windows.Forms.Button.WndProc(Message& m)
> > > > > >   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&
> m)
> > > > > >   at System.Windows.Forms.ControlNativeWindow.WndProc(Message&
m)
> > > > > >   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,
Int32
> > > msg,
> > > > > > IntPtr wparam, IntPtr lparam)
> > > > > >
> > > > > >
> > > > > > ************** Loaded Assemblies **************
> > > > > > mscorlib
> > > > > >    Assembly Version: 1.0.5000.0
> > > > > >    Win32 Version: 1.1.4322.573
> > > > > >    CodeBase:
> > > > > >
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
> > > > > > ----------------------------------------
> > > > > > System.Drawing
> > > > > >    Assembly Version: 1.0.5000.0
> > > > > >    Win32 Version: 1.1.4322.573
> > > > > >    CodeBase:
> > > > > >
> > > >
> > >
> >
>
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
> > > > > > ----------------------------------------
> > > > > > System
> > > > > >    Assembly Version: 1.0.5000.0
> > > > > >    Win32 Version: 1.1.4322.573
> > > > > >    CodeBase:
> > > > > >
> > > >
> > >
> >
>
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
> > > > > > ----------------------------------------
> > > > > > RegexAssembly4_0
> > > > > >    Assembly Version: 0.0.0.0
> > > > > >    Win32 Version: n/a
> > > > > >    CodeBase:
> > > > > > ----------------------------------------
> > > > > > IEExecRemote
> > > > > >    Assembly Version: 1.0.5000.0
> > > > > >    Win32 Version: 1.1.4322.573
> > > > > >    CodeBase:
> > > > > >
> > > >
> > >
> >
>
file:///c:/windows/assembly/gac/ieexecremote/1.0.5000.0__b03f5f7f11d50a3a/ieexecremote.dll
> > > > > > ----------------------------------------
> > > > > > PrintTest
> > > > > >    Assembly Version: 1.0.1468.23656
> > > > > >    Win32 Version: n/a
> > > > > >    CodeBase:
> http://192.168.0.33/VistaNETtest/Testing/PrintTest.EXE
> > > > > > ----------------------------------------
> > > > > > System.Windows.Forms
> > > > > >    Assembly Version: 1.0.5000.0
> > > > > >    Win32 Version: 1.1.4322.573
> > > > > >    CodeBase:
> > > > > >
> > > >
> > >
> >
>
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
> > > > > > ----------------------------------------
> > > > > > System.Xml
> > > > > >    Assembly Version: 1.0.5000.0
> > > > > >    Win32 Version: 1.1.4322.573
> > > > > >    CodeBase:
> > > > > >
> > > >
> > >
> >
>
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
> > > > > > ----------------------------------------
> > > > > > Microsoft.VisualBasic
> > > > > >    Assembly Version: 7.0.5000.0
> > > > > >    Win32 Version: 7.10.3052.4
> > > > > >    CodeBase:
> > > > > >
> > > >
> > >
> >
>
file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
> > > > > > ----------------------------------------
> > > > > >
> > > > > > ************** JIT Debugging **************
> > > > > > To enable just in time (JIT) debugging, the config file for this
> > > > > > application or machine (machine.config) must have the
> > > > > > jitDebugging value set in the system.windows.forms section.
> > > > > > The application must also be compiled with debugging
> > > > > > enabled.
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
>


Relevant Pages

  • Re: This rock, this watery pearl, this pale blue dot.
    ... You have people of every field, you have everything safe and food ... size, and we the keepers of it, well they should have got keepers with ... And you will donate whatever 200 dollars each or some base tax and ... little old ladies on farms in Saskatewan for permission and they would ...
    (sci.physics)
  • Re: Adding permissions to predefined permission sets
    ... The information concerning an inability to modify the predefined permission ... could modify security policy directly by changing those files and was ... > need to copy the permission set, modify it, then change the permission set ...
    (microsoft.public.dotnet.security)
  • Re: Security Exception when downloading Assembly from IIS
    ... The following applies to a managed user control intended to execute with greater permissions than would normally be granted to the zone the assembly belongs to, most likely either Internet, Local Intranet or Trusted Sites. ... The client has a code group that the assembly resolves to that grants the permissions the assembly requires. ... > permission. ... when I grant the assembly the FullTrust permission set. ...
    (microsoft.public.dotnet.security)
  • Re: Adding Code Access Security
    ... > The website recognizes it as a safe control but doesn't give it File ... > permission to the assembly and the site no longers recognizes the Web ... > Before altering the policy for the assembly I checked to see if I had ... > one hex value in the IMembershipCondition PublicKeyBlob. ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: Adding Code Access Security
    ... > The website recognizes it as a safe control but doesn't give it File ... > permission to the assembly and the site no longers recognizes the Web ... > Before altering the policy for the assembly I checked to see if I had ... > one hex value in the IMembershipCondition PublicKeyBlob. ...
    (microsoft.public.sharepoint.windowsservices)