Showing posts with label SharePoint 2010. Show all posts
Showing posts with label SharePoint 2010. Show all posts

Thursday, March 28, 2013

How to find SharePoint farm ID in Configuration database


To find Farm ID the following SharePoint Management shell (or PowerShell) command could be used:

$spFarm=[Microsoft.SharePoint.Administration.SPfarm]::Local
$spFarm.Id

Farm ID could be also found in Configuration database by running the following SQL query:


SELECT * From Objects where ClassId = ’674DA553-EA77-44A3-B9F8-3F70D786DE6A’

The '674DA553-EA77-44A3-B9F8-3F70D786DE6A' GUID is always a ClassID for Farm object.

More information here

Wednesday, October 24, 2012

How to suppress SharePoint 2010 ribbon based on permissions


Have you ever noticed how in SharePoint 2010 Owners see the ribbon and can click Site Actions/Browse/Page, and Readers see the ribbon too but there is no any actions or tabs to click and they see dark blue band. In some cases there is nothing else going on up there for Readers. It is wasted real estate!
Owner:
 
Reader:
 
The Reader can use all the extra space for some website goodness!
This is easy to solve.
- Open the master page, find the div tag: <div id="s4-ribbonrow"- Put the following around it: 
<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ManageWeb"><div id="s4-ribbonrow" …</div></SharePoint:SPSecurityTrimmedControl>

From here

Monday, October 15, 2012

Restarting IIS after installing/removing/upgrading SharePoint solution

Do I need to restart IIS after installing/removing/upgrading solution?

The answer is simple - YES.

Found few articles explaining it:

SharePoint Solution Deploy, retract, upgrade – What causes your SharePoint farm to go offline IISRESET (web server outage)


Deploying a solution

Initially, the package manifest.xml is checked for its content & destination locations. The files specified in the manifest.xml are copied to the locations. After solution files are copied to the target servers, a configuration reset is scheduled for all front-end Web servers; the reset then deploys the files and restarts Microsoft Internet Information Services (IIS). Farm administrators can specify when this occurs (a timer job).
Reference: http://msdn.microsoft.com/en-us/library/aa544500.aspx


Retracting a solution

On each front-end Web server, the following occurs:
- Internet Information Services (IIS) is disabled.
- Files are removed from the system.
- IIS is re-enabled and Microsoft SharePoint Foundation is reloaded when a user browses to a page.

- Farm administrators can specify the time when the retraction takes place.


Upgrading a solution

There are two ways to do an upgrade of a solution. i.e. Replacement and Update. Both inolve a an IISRESET.
Replacements are essentially a retract and optionally removal of a WSP. Then the new version is added and deployed. Causing an IISRESET (twice!).
Updates are essentially a deployment with the same file name but different GUID. SharePoint detects this and retracts the old solution and deploys the new one..causing an IISRESET.
Please note that there is a -local option when deploying a solution, but according to MSDN, this is to be used for troubleshooting purposes.
Reference: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spsolution.deploylocal.aspx


Why do we need to restart IIS after copied DLLs into Assembly
We restart the IIS to reset Application pool as lot of things in SharePoint are cached. The alternative option is you can recycle the application pool of the application for which you have deployed the WSP or DLLs

Deploying solutions with no downtime

Found interesting article about deploying solutions with no downtime


The most important attribute we need to remember is the –Local attribute this will only ensure that the solution deployment will only occur on the local server.
Other attributes include:-
  • WebApplication – this will deploy the solution to a specific Sharepoint Web Application
  • GacDeployment – this option allows a solution which contains .NET assemblies to be installed in to the GAC to be installed.
  • CasPolicies – this option allows a solution which contains code access security policies for the assemblies / web parts to be deployed.

Saturday, October 6, 2012

Finding what site definition is used by a SharePoint site

If you're performing SharePoint migration, you might face an issue with custom site definitions (or templates) site are based on. Or you might want to know what out of the bow definition was used for a site.

To find the template there are different options:
  1. Using SharePoint Manager tool [available for 2007, 2010 and 2013.] Download it for free from Codeplex and install it. Then open the SharePoint Manager and connect to the SharePoint site collection. When you click on a specific SharePoint site, on the right side it will show you all the properties available in the SP object model for that site. Find WebTemplate and Configuration values for the site:
  2. If there is no way to install SharePoint Manager or if any other problems, then save the current site as site template [.STP or .WSP extension]. And save it to disk somewhere. Navigate to that location and rename the file to .CAB extension. Extract the CAB file.If it is SharePoint 2007 you will find manifest.xml file that contains TemplateID and Configuration of the site:

    If it's SharePoint 2010 open the folder that ends with "
    WebTemplate" and open Elements.xml. Find BaseTemplateName and BaseConfigurationID in the file:



     Navigate to end of this post for the TemplateID to Name mapping.
  3. Through managed code we can identify this very easily with the below code:

    view plaincopy to clipboardprint?
    using (SPWeb web = site.OpenWeb("/"))
    {    
       string templateID = web.WebTemplateId.ToString();
    }
  4. Using STSADM.EXE. It needs high level permissions. Means the user should be an administrator on the server. Below is the command we need to use for knowing the site template.
    stsadm.exe -o enumallwebs -databasename [content database name]
  5. Using SQL Management Studio you can execute the below query on the content database of the site collection.
    SELECT Title, WebTemplate, ProvisionConfig FROM dbo.Webs WHERE Title='Test Publishing Site'

Choose one option which is useful or easy for you and identify the correct template.


Site template ID to Name mapping:
0 - GLOBAL (SetupPath=global) - "Global template"
1 - STS - "windows SharePoint Services Site", STS#0 - "Team Site", STS#1 - "Blank Site", STS#2 - "Document Workspace"
2 - MPS - MPS#0 - "Basic Meeting Workspace", MPS#1 - "Blank Meeting Workspace", MPS#2 - "Decision Meeting Workspace", MPS#3 - "Social Meeting Workspace",  MPS#4 "Multipage Meeting Workspace"
3 - CENTRALADMIN - "Central Admin Site"
4 - WIKI - "Wiki Site"
7 - BDR - "Document Center"
9 - BLOG - "Blog"
20 - SPS (OBSOLETE) - "SharePoint Portal Server Site"
21 - SPSPERS - "SharePoint Portal Server Personal Space"
22 - SPSMSITE - "Personalization Site"
30 - SPSTOC (OBSOLETE) - "Contents area Template"
31 - SPSTOPIC (OBSOLETE) - "Topic area template"
32 - SPSNEWS (OBSOLETE) - "News area template"
33 - SPSNHOME (SubWebOnly) - "News Home template"
34 - SPSSITES - "Site Directory area template"
36 - SPSCOMMU (OBSOLETE) - "Community area template"
38 - SPSREPORTCENTER - "Report Center Site"
39 - CMSPUBLISHING (SubWebOnly) - "Publishing and Team Collaboration Site"
40 - OSRV  - "Shared Services Administration Site"
47 - SPSPORTAL - "Corporate Intranet Site"
50 - SRCHCEN - "Search Center"
51 - PROFILES - "Profiles"
52 - BLANKINTERNETCONTAINER - "Internet Presence Web Site"
53 - BLANKINTERNET (SubWebOnly)BLANKINTERNET#0 - "Publishing Site", BLANKINTERNET #1 - "Press Releases Site", BLANKINTERNET#2 - "Publishing Site with Workflow"
54 - SPSMSITEHOST - "My Site Host"
56 - ENTWIKI - "Enterprise Wiki"
90 - SRCHCENTERLITE (SetupPath=SiteTemplates\SRCHCENTERLITE) - "Search Center Lite"
6221 - PWA (SetupPath=SiteTemplates\PWA) - "Project Web Access Site"
6215 - PWS (SetupPath=SiteTemplates\PWS) - "Project Workspace"
14483 - OFFILE - "Records Repository", "Records Repository"


Tuesday, October 2, 2012

SharePoint site templates vs site definitions.

Site Template
  • A site template (*.stp file) is created through the user interface or through implementation of the object model. It is a package containing a set of differences and changes from a base site definition.
  • The site template package is stored as a CAB-based file that can be downloaded or uploaded to site collections by users with the appropriate rights. As before, site templates offer a measure of portability to SharePoint Applications.
  • It is not as fast as a pure site definition as site definitions are cached on start of IIS on the web front ends while site templates are stored and hence need to be fetched from the content database and merged with the site definition code at runtime to render the site.
  • Also note that if you plan to transfer a site template to separate farm, that the farms have the same versions installed of SharePoint installed.  (hotfixes,etc.) This is due to the dependence site templates have on the original base site definition they were created from.
Site Definition
  • The core definition of what a site is in SharePoint.
  • It is installed on file system of web front ends, located at ..\12\Template\SiteTemplates. This directory is language-neutral.
  • It consists of .aspx pages and .xml files with Collaborative Application Mark-up Language (CAML).
  • A major benefit is that the Page and List definition is read locally from the file system, not from Content Database.
  • A site definition Page and List definition are cached at the IIS process start up
  • Customizations made to site definition are stored in content database, not on the file system. This can be performed via SharePoint Designer, or when custom site templates are saved.
  • Site Definitions are developer created
  • Localization: WSS 3.0 supports full site template localization (based on ASP.Net 2.0 via XML files and .ASPX files pulling strings from RESX files. Therefore solutions can be shipped “language packs” of resource files.
  • “Global Template” defines commonality across site definitions; it gets called before any other template. It works by injecting common provisioning content into all new sites. ONET.XML file defines base types, galleries, mobile redirects
  • Data is stored directly on the Web servers, so performance is typically better.
  • A higher level of list customization is possible through direct editing of a Schema.xml file.
  • Certain kinds of customization to sites or lists require use of site definitions, such as introducing new file types, defining view styles, or modifying the Edit menu.
  • Customization of site definition requires more effort than creating custom templates.
  • Editing a site definition after it has been deployed is difficult.
  • Doing anything other than adding code can break existing sites.
  • Users cannot apply a SharePoint theme through a site definition.
  • Users cannot create two lists of the same type with different default content.
  • Customizing site definitions requires access to the file system of the front-end Web server.
  • Custom templates are easy to create.
  • Almost anything that can be done in the user interface can be preserved in the template.
  • Custom templates can be modified without affecting existing sites that have been created from the templates.
  • Custom templates are easy to deploy.
  • Custom templates are not created in a development environment.
  • Custom templates are less efficient in large-scale environments.
  • If the site definition on which the custom template is based does not exist on the front-end server or servers, the custom template does not work.

Custom site definitions hold the following advantages over custom templates:

  • Data is stored directly on the Web servers, so performance is typically better.
  • A higher level of list customization is possible through direct editing of a Schema.xml file.
  • Certain kinds of customization to sites or lists require use of site definitions, such as introducing new file types, defining view styles, or modifying the Edit menu.


Site definition disadvantages include the following:

  • Customization of site definition requires more effort than creating custom templates.
  • Editing a site definition after it has been deployed is difficult.
  • Doing anything other than adding code can break existing sites.
  • Users cannot apply a SharePoint theme through a site definition.
  • Users cannot create two lists of the same type with different default content.
  • Customizing site definitions requires access to the file system of the front-end Web server.


Custom templates hold the following advantages over customization of site definitions:

  • Custom templates are easy to create.
  • Almost anything that can be done in the user interface can be preserved in the template.
  • Custom templates can be modified without affecting existing sites that have been created from the templates.
  • Custom templates are easy to deploy.


Custom template disadvantages include the following:

  • Custom templates are not created in a development environment.
  • Custom templates are less efficient in large-scale environments.
  • If the site definition on which the custom template is based does not exist on the front-end server or servers, the custom template does not work.




Friday, April 27, 2012

Read permissions not working


Some possible reasons and solutions:
http://sharepoint.stackexchange.com/questions/6308/access-denied-for-read-only-group
As it turns out, I had modified the master page for the site when it was first created, then never published it to the site. Once the page was published, I was able to access the site with read-only permissions.


http://blog.tylerholmes.com/2008/02/troubleshooting-access-denied-errors-in.html
Based in URL on Access denied page we can gind a list that causes the issue.

Master page gallery has unique permissions and user does not have permissions for it.

Friday, April 6, 2012

Multi-day reoccurring events in SharePoint

I did not know that you're not able to create a multi-day reoccurring event in SharePoint.
There are a lot of discussions  about that.

Basically, as soon as you check "Make this a repeating event", the date field for Start/End Time disappears:

That's valid for both SharePoint 2007 and 2010.

Hmm... how would create an event to show that I have Friday-Sunday off every week for example? Well, it may be not a real case, but the real one is migrating Outlook Calendars to SharePoint.

Friday, February 10, 2012

SharePoint 2010 Web Parts by License Type

The official SharePoint site contains a comparison of the features in each SharePoint 2010 edition but does not include specific details on what web parts are available for each SKU/license type. This is useful to know when choosing between Foundation vs Standard vs Enterprise, as this additional functionality may be a good reason to upgrade (or turn on these features for specific users). It is also useful to know these as a developer or solution architect so you don’t custom develop something that has already been built and tested by Microsoft – something that I often see happen.


http://www.sharepointconfig.com/2010/06/sharepoint-2010-web-parts-by-license-type/

Thursday, December 8, 2011

Installing SharePoint solution under the hood

Great table explaining states during installing/uninstalling solutions:

Central AdminSite/Web Level FeaturesGACWeb.Config14-RootFeaturesSharePoint Config DB, Objects Table – SolutionsSharePoint Config DB, Objects Table – FeaturesWeb App Content DB, Features Table
Add-SPSolutionSolution Added but Not DeployedN/AN/AN/AN/ASolution Definition AddedN/AN/A
Install-SPSolutionDeployed to Web AppInstalled FeatureDLLs AddedSafe Control Entries AddedFeatures AddedSolution Definition Still ExistsFeature Definition AddedN/A
Enable-SPFeatureSolution Still DeployedActivated feature to Site/WebStill ExistsStill ExistsStill ExistsSolution Definition Still ExistsFeature Definition Still ExistsFeature Activation Link Added
Disable-SPFeatureSolution Still DeployedDeactivated feature from Site/WebStill ExistsStill ExistsStill ExistsSolution Definition Still ExistsFeature Definition Still ExistsFeature Activation Link Deleted
UnInstall-SPFeatureSolution Still DeployedUninstalled featureStill ExistsStill ExistsStill ExistsSolution Definition Still ExistsFeature Definition DeletedN/A
UnInstall-SPSolutionRetracted from Web AppUninstalled featureDLLs DeletedSafe Control Entries DeletedFeatures DeletedSolution Definition Still ExistsFeature Definition DeletedN/A
Remove-SPSolutionSolution DeletedN/AN/AN/AN/ASolution Definition DeletedN/AN/A


The above table has been taken from here: Install/Uninstall table

Installing (MSDN)

Uninstalling (MSDN)

Thursday, November 17, 2011

Delete SharePoint orphan site

If you can see the site in database, but not in Central Administration


stsadm -o deletesite -force -siteid e2a114b8-80c9-41f6-87bf-3feddf2ad9b6 -databaseserver DS1 -databasename DB1


http://technet.microsoft.com/en-us/library/cc288016(office.12).aspx

Wednesday, October 26, 2011

Managed Metadata in SharePoint 2010

I've found an excellent explanation of difference between Global and Local term sets:
Local vs Global term sets

The above blog contains the following useful information as well:


SharePoint 2010 Managed Metadata
What is it? 
Why I love it!
Global vs. Local Term Sets
Moving/Copying MMS Instances / Term Stores between Environments 
In Depth Look into the Taxonomy Parts
Creating Managed Metadata Columns


When I've created a new site for testing and added a managed metadata column to a list, I've got the following message: "The required feature is not enabled for this column type".

The following command should be executed:

Enable-SPFeature -id "73ef14b1-13a9-416b-a9b5-ececa2b0604c" -Url <Site-Url>

Refer to the following article for more details.


Wednesday, July 6, 2011

Farm Admin in SharePoint 2010

When you add a user into Farm Administrators group in SharePoint 2007 it automatically added as db_owner for the config database. So, I assumed SP2010 works the same way, but it does not.

When you add a user into Farm Administrators group it is automatically added into WSS_ADMIN_WPG group only. 

Refer to the following article to find out which permissions the group has.
In few words it has permissions to system folders on the SP server.
The account does not have direct access to SQL databases, so there will be problems for any third party tools which work with SharePoint through API

The difference is that when you're working with SharePoint via Central Administration you're actually working with databases under Application Pool account. But when you're working via API (SharePoint Object Model for example) you're working in the context of the account executing API calls. So, to get the API calls working you should grant direct access to SharePoint databases.


If you do not want to grant direct access to configuration database you can use PowerShell command:
Add-SPShellAdmin –username <String>
The command adds the user to the SharePoint_Shell_Access role. In fact, those users who included in the role have db_owner access to the Configuration database.
To get a list of users included into the group execute the following comm and:
Get-SPShellAdmin
Refer to the following article for details about required permissions to run PowerShell.
Refer to the following article for details about the SharePoint_Shell_Access role.

Also if you receive the error message when using STSADM, that may mean you run it under a Farm Administrator user who does not have direct access to SP databases. The error message is the following:

This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.

Friday, May 6, 2011

SharePoint works slow for the first time after restart

Ever thought things on ASP.NET were a bit slow the first time accessing them? Many of you are aware that ASP.NET from a web admin perspective know that things have to recompile and things just aren't as fast the first time. In fact some times things are incredibly slow the first time and are incredibly slow. Ever had users say, for some odd reason some times when I hit my SharePoint site it takes 30 seconds to load, then after a refresh it goes sub second, even clearing their cache the page is fast. That's because it's not a user issue, its simply compiling, caching, etc... on the server after an IISReset or app pool reset or worker process cycle.

Read the whole Joel Oleson post

Saturday, November 13, 2010

Executing PowerShell script for SharePoint in msi.

If you want to execute PowerShell script in msi written with WIX you may face some problems. Here I explain issues I had in my project:
To execute the script you need to create custom action which runs PowerShell. Note that you cannot run SharePoint Management Shell (at least I didn't find how to do that :). But you can run PowerShell and load SharePoint snap-in inside the script:


<CustomAction Id="PSExecute" Property="PS" ExeCommand="&'[FOLDER]\install-extension.ps1'" Execute='deferred' Return='check'/> 


The script execution may fail due to some reasons. For example, SharePoint Administration service is not running, PowerShell Execution Policy prevents scripts from running, you run msi under account who is not SharePoint Farm administrator. Maybe there are another reasons that I don't know yet ;)

When the script is executed from msi, the PowerShell console is running but you should be a very fast person to catch its output :) So, it is required to add logging into your script. Using Start-Transcript is the only that I'm able to use. Refer to the following post for more information about Start-Transcript.

One more useful thing is "throw 'ERROR'" to abort the script execution if needed. For example SP-GetObject and SP-AddSolution cmdlets may throw errors during execution but they will not cause the script to be completed with error. And installer completes successfully but it actually does not do anything. You can add throw 'ERROR' where is needed and installation ends with Fatal Error.

Monday, August 23, 2010

Document Property Parsing in SharePoint

When you upload, move, or copy a file to a document library, Windows SharePoint Services determines if a parser is associated with the document's file type. The parser extracts all the properties and matching property values from the document, and adds them to the property bag object. Windows SharePoint Services accesses the document property bag and determines which properties match the columns for the document. It then promotes those properties, or writes the document property value to the matching document library column.
Windows SharePoint Services can also invoke the parser to demote properties, or write a column value into the matching property in the document itself.
Usefull Links:

Thursday, June 10, 2010

Gradual Site Delete: Gradual deletion of site collection in SharePoint 2010

When you delete a Site collection in SharePoint 2010 from Central Administration or from the site collection settings it is deleted gradually.
The gradual deletion is performed by the Timer Job Definition called Gradual Site Delete.
In few words:
The site reference is being deleted from SiteMap and Sites tables of configuration and content databases and added into the SiteDeletion table. The Site collection is unavalaible for users. But sub-sites still exist in the Webs table of content database. This behavior can cause some issues for third-party tools which read these tables.
The Gradual Site Delete Timer Job definition is scheduled to be runnin one time a day. It can be started manually from Central Administration -> Monitoring -> Review job definitions -> Gradual Site Delete.
Here you can edit the timer job or run the job immediately

Refer the following article for more detailed information about the Gradual Site Delete timer job definition.

To delete the site collection completely use the following Powershell command:
Remove-SPSite -Identity ""

Wednesday, May 26, 2010

SharePoint 2010 wiki home page

When you create a SharePoint 2010 site based on the team site template it automatically activates WikiPageHomePage feature. So, when you open the created site it opens with the SitePages/home.aspx home page.
But the default.aspx page is still there. If you navigate to the team site and append default.aspx to the end of the url, http://host/sites/teamsite/default.aspx, you will notice it takes you to a page very much like the previous 2007 version of SharePoint.
The feature is not activated automatically on Blank site (STS#1) or Document workspace (STS#2)
For more details about the WikiPageHomePage feature refer the following article

Usefull links:
How to change the wiki home page programmatically: