SandBox
Solutions
SharePoint enables end users to customize their SharePoint
sites to a certain degree, some customizations can only be made by deploying
custom code and custom assets to the server via a solution. However, only a farm
administrator has the ability to deploy a solution to the farm. In some cases,
farm administrators don ’ t have the available time to deploy solutions in a
timely manner, leaving end users frustrated that their solutions are not
being
deployed as quickly as they would
like. Furthermore, if a solution is deployed globally, particular features could
become available to all site collections across the farm. This could be
undesirable, especially in environments with hundreds or thousands of site
collections, and especially in hosted environments in which one site -
collection owner should be unaware of any activity in any other site collection on the server.
What Are Sandboxed
Solutions?
SharePoint 2010 has introduced
the concept of sandboxed solutions. A sandboxed solution is one that can be
uploaded to a specifi c site collection by a site - collection administrator
using a browser.
By providing this functionality,
site administrators are no longer required to wait for their farm administrator
to deploy their solution because they can do it themselves. In addition,
sandboxed solutions are applied only to the site collection to which they have
been uploaded.
No other site collection has any knowledge of the
solution ’ s existence, just as another site collection would not be aware that a document had been uploaded to a document
library in another site collection.
As great an idea as this might
seem, because solutions deployed this way are not required to go through a
thorough vetting process this approach could cause havoc in a farm for several
reasons:
A single solution deployed to a
single site collection could potentially consume so many server resources that
it bogs down the entire server. Because the farm administrator isn ’ t
necessarily aware of the sandboxed solution ’ s existence (it was uploaded
without his knowledge), he would not immediately know why his server was
performing slowly. It could potentially take some time to fi gure out the source
of the problem.
A malicious or clumsy programmer
could write code inside a solution that accesses objects in the farm, such as
other site collections or even web applications.
A sandboxed solution deployed
without a farm administrator ’ s consent could potentially delete web
applications and otherwise bring down the farm.
Microsoft has provided a solution
to each of these problems:
Farm administrators can specify a
threshold of server resources (a combined value that takes into account things
like CPU and memory usage) that a site collection ’ s sandbox can
use.
Once that threshold has been met
in a particular site collection, all the sandboxed solutions in that site will
be turned off for the rest of day. (Clearly, this is a stop - gap measure to
protect the server. The goal is for your solutions to not consume so many
resources that they exceed that quota in a day.)
Sandboxed solutions do not run
with full trust in the web application; instead, they run with a custom code
access policy that grants them minimal permissions.
A limited API is available to
sandboxed solutions, eliminating the ability for sandboxed solutions to access
anything in the object model above the site collection (such as the web
application or farm objects), or allowing code in sandboxed solutions to run
with elevated privileges.
Sandboxed solutions cannot deploy any files to the
SharePoint root folder, and they cannot deploy objects such as site definitions and
workflows.
When a sandboxed solution is deployed, any features
associated with it are automatically activated.
A Comparison of Farm and Sandboxed
Solutions
FARM
|
SANDBOXED
|
Assemblies are placed in the GAC or in the Bin
directory of a SharePoint web application.
Assemblies placed in the GAC are fully trusted, whereas
assemblies placed in the bin directory of a web application can be partially
trusted.
Assembly execution takes place in the webServer process
(w3wp.exe).
|
Any assemblies associated with a solution are
extracted, kept in memory, and executed within a special worker process
called
SPUCWorkerProcess.exe.
This isolates the execution of sandboxed solutions from the
Operations of the underlying web
process.
|
Solutions must be installed and deployed by a farm
administrator
|
Solutions can be installed and deployed by asite
administrator
|
There are no limitations on which SharePoint classes
and objects can be used in farm solution Assemblies.
|
Developers must leverage a subset of theSharePoint API
when developing sandboxedSolutions.
|
Solutions will use however many server resources are
necessary
|
Farm administrators have the ability to throttleThe
server resources used by a given
solution.
|
Sandboxed solutions are deployed to the Solution
gallery in a given site collection. You can view the Solution gallery by
navigating to the Site Settings page in the root site of the site collection,
then clicking the Solutions link under the
Galleries heading.
SandboxedSolutions.ps1 using
Powershell
Add-SPUserSolution -LiteralPath
C:\Solutions\MySolution.wsp
-Site
http://sitename
Install-SPUserSolution -Identity
MySolution.wsp
-Site
http://sitename
Uninstall-SPUserSolution
-Identity MySolution.wsp
-Site
http://sitename
Remove-SPUserSolution -Identity
MySolution.wsp
-Site
http://sitename
Update-SPUserSolution -Identity
MySolution.wsp
-Site http://sitename -ToSolution
MySolutionV2.wsp
Get-SPUserSolution
-Identity MySolution.wsp -Site http://sitename
Farm Solutions
Farm solutions cannot be installed
using a browser the way that sandboxed solutions can be.
Instead,
PowerShell is needed. To install a farm solution, use the Install - SPSolution
PowerShell command. This will add the solution to the solution store in Central
Administration.To find the solution store, navigate to the Central
Administration website and click the System Settings link in the navigation on
the left side of the page. Under the heading Farm Management,click the link that
says Manage Farm Solutions. This will take you to the Solution Management
page.Clicking a solution in the list brings up a page for managing the solution
properties. This page shows when and where the solution was deployed (if at
all). In addition, the toolbar has buttons for deploying or retracting the
solution. If the solution deploys globally, no confi guration is required beyond
simply deploying the solution. Otherwise, the Deploy To? section will have a
drop - down list containing the web applications in the farm. By selecting an
item from the list, a user can select the web application to which the solution
will be deployed. In the same way, the user can choose the web application from
which the solution should be retracted, when applicable. Once a solution has
been completely retracted from every location in the farm, it can be removed by
clicking the Remove Solution button in the toolbar.As with sandboxed solutions,
PowerShell can be used to add, deploy, retract, remove, and upgrade
solutions.
Farm Solutions Using
Powershell
Add-SPSolution -LiteralPath
C:\Solutions\MySolution.wsp
Install-SPSolution -Identity
MySolution.wsp -GACDeployment
Install-SPSolution -Identity
MySolution.wsp
-WebApplication IntranetSite
Uninstall-SPSolution -Identity MySolution.wsp
Uninstall-SPSolution -Identity MySolution.wsp
-AllWebApplications
Remove-SPSolution -Identity
MySolution.wsp
Update-SPSolution -Identity MySolution.wsp
-LitearlPath C:\Solutions\MySolutionV2.wsp
-GACDeployment
Get-SPSolution -Identity MySolution.wsp
-Identity
MySolution.wsp -Site http://sitename
No comments:
Post a Comment