20
Deploying binaries to the bin folder Partially Trusted Code in SharePoint Corey Roth Stonebridge Twitter: @ coreyroth Blog: www.dotnetmafia.com

Deploying Binaries To The Bin Folder Share Point Saturday Kc 2009

Embed Size (px)

DESCRIPTION

Slides from my talk at SharePoint Saturday Kansas City December 2009 about deploying partially trusted code in SharePoint 2010.

Citation preview

Page 1: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Deploying binaries to the bin folderPartially Trusted Code in SharePoint

Corey RothStonebridgeTwitter: @coreyrothBlog: www.dotnetmafia.com

Page 2: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Corey RothConsultant for Stonebridge in Tulsa, OKWorked in Consumer Electronics, Travel, Advertising, and Energy industriesCurrently doing SharePoint development specializing in Enterprise SearchMicrosoft Solutions AdvocateMicrosoft Award for Customer Excellence (ACE) WinnerE-mail: [email protected] Twitter: @coreyrothBlog: www.dotnetmafia.com

Page 3: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

What is Partial Trust?

Page 4: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Why use Partial Trust?More SecureAllows deployment of assemblies to bin folderDeployment doesn’t require an Application Pool resetDoesn’t require giving every deployed DLL full trust

Page 5: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Demo

Page 6: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Implementing Partial TrustAdd [Assembly: AllowParitallyTrustedCallers()] to AssemblyInfo.csSet <trust Level=“Minimal” originUrl=“” /> in web.configDefine Security Policy in Trust configuration fileSecurity policy can be deployed via solution package (.wsp) using manifest.xmlPowerShell: Install with Install-SPSolution and –CASPolicies parameterWSS3: Install with stsadm and –allowCasPolicies parameter

Page 7: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Visual Studio 2010CAS policies configured in Package Editor manifest tabStill must configure permissions manuallySet Assembly Deployment Target to WebApplication on project properties

Page 8: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Demo

Page 9: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

How do I determine CAS policy?Google

ReflectorExceptionsDotNetMafia.com

Page 10: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

<CodeAccessSecurity>Element in trust configuration file that defines which CAS Policies apply to each assembly<IPermission> element defines individual rights to resources such as ASP.NET, SharePoint, EventLog, Configuration, SQL Server, File I/OCan be copied to configuration file manually or deployed via solution package (wsp)

Page 11: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

<IPermission>AspNetHostingPermission (Level=“Minimal”) – Required for ASP.NET ControlsSharePointPermission (ObjectModel=“True”) – Required to use SharePoint APIFileIOPermission (Read, Write, PathDiscovery, Append) – Specifies files the code can access - $AppDir$ by defaultSqlClientPermission – Required to access SQL ServerReflectionPermission – Required for LINQSecurityPermission – Required for most basic operationsEnvironmentPermission – Provides access to environment variables

Page 12: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

What the solution package doesBacks up your web.config

Changes the trust element to WSS_Custom in web.configBacks up trust configuration file – wss_minimaltrust.config becomes wss_custom_wss_minimaltrust.configChanges the path to the trust configuration file in the web.config <trustLevel> elementAdds code access security settings from manifest.xml

Page 13: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Demo

Page 14: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Sandboxed SolutionsVariation of Code Access Security but more restrictivePermissions configured in wss_UserCode.xml in the 14\CONFIG folderOnly allows use of ASP.NET controls and some of the SharePoint object model

Page 15: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Demo

Page 16: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

What requires full trust?Event ReceiversVisual Web PartsTimer JobsPowerShell commandletsSTSADM Commands

Page 17: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Questions?

Page 18: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Thank you sponsors!!

Page 19: Deploying Binaries To The Bin Folder   Share Point Saturday Kc 2009

Remember to fill out your evaluations for your chance to win

cool prizesKodak Zi8 HD Pocket Video Camera 2 HP Netbook’s

Also Tons of books2 thinkgeek giftcards for $100 Telerik rad controls set2 licenses of essential user interface studio1 webcast from critical pathMicrosoft Zune