Posts

Showing posts from 2011

Force FBA users to download word document instead of having them open in MS Word

FBA users when opening documents get either prompted with login or MS Word opens up the document and it is either blank or just a new document.

Way i found round this problem is to force them to download the document by going to Central Admin \ Select webapplication\ Authentication provider\ Set Enable Client integration to No.



Anonymous user gets prompted to view list items even through they have view list item permissions

In a publishing site even if anonymous users have been granted permission on all the level i.e in Central admin, in Site and if permissions are broken then in List\ Libraries but still they get prompted to enter username\ password to view the list\ list items.
To fix this issue deactivate a hidden feature by name ViewFormPagesLockDown, this feature when active denies access to anonymous users to all pages of type "application pages" by prompting authenication.
Below is the command to deactivate it, after deactivating it turn off\ on anonymous authentication on all the 3 level i.e
in CA for the webapplication, in Site collection and
finally in any lists that you have broken permissions.

stsadm -o deactivatefeature -url http://yourserver -filename ViewFormPagesLockDown\feature.xml

Below is a MS link to configure anonymous access in sharepoint.
http://office.microsoft.com/en-us/sharepoint-server-help/grant-permissions-to-anonymous-users-HA101805390.aspx

Converting a site to a Site collection

Creating a site collection from site











1. Below I am creating a new database, since my site is a publishing site I will be creating a blank publishing site.


create new site in its own DB using the below cmstemplate


a. $w=Get-SPWebApplication("http://shareptapptest:9002")






b. New-SPContentDatabase "WSS_Content_Internet_Hosted_Sites_3" -DatabaseServer "shareptDBtest" -WebApplication $w






c. new site : here I am creating a blank publishing template which cannot be created from UI


New-SPSite http://shareptapptest:9002/hostedsites -OwnerAlias testdomain\testadmin -Name "SITENAME" -Template "cmspublishing#0"










2. Export the site http://shareptapptest/hostedsites/SUBSITE :






stsadm -o export -url http://shareptapptest/hostedsites/SUBSITE -filename "C:\Deployments\Release2-Technical Upgrade\SUBSITE06142011.bak"






3. Makig sure all site collection and sub site features\ spolutions are activated on the new site collection


a. Make sure all solutions are ac…

LinQ to SharePoint examples

Namespaces to refer in Visual studio for using LinQ

using System.Linq;
using Microsoft.SharePoint.Linq;
using System.Collections.Generic;

Generate Entity classes using SPMetal
Run the following command to generate it
spmetal /web:http:// /code:

Creating a Join between two list UserAccounts and Invoices.
List UserAccounts have Account, Name
List Invoices have Account, Amount, Paid

//First refer the Datacontext class
XDataContext a = new XDataContext(SPContext.Current.Web.Url);


//Refere the Lists and create entityLists out of them

EntityList Invoices = a.GetList("Invoices") ;
EntityList UserAccounts = a.GetList("UserAccounts");

//need to do a join from the two lists and bring them together.
//use the ToList() on the list in the from to avoid getting errors due to inefficient CAML queries. with this method it retrives data from the list instantaniously.

var query=
(from u in UserAccounts.ToList()
join i in Invoices on u.Account equals i.Account
where int.Parse(u.Account.…

Host header site collection VS Path based Site Collections in SharePoint 2010

SharePoint gives the ability to create site collections with it's own domain name while the web application has a different domain name, these site collections are called host name site collections and their creation and behaviour is different from regular path based site collections which by default are created under http://sp2010/SITES/XYZ/. Below are 10 differences that i could gather which lays out the difference between hostname site collections and path based site collections.
1. SharePoint 2010 Support
Host-Header Site Collection : Yes
Path Based Site Collection : Yes

2. DNS Support
Host-Header Site Collection : Unique DNS name for each site collection i.e. www.customer1.com, www.customer2.com or *.customer1.com

Path Based Site Collection : Will to be the same as the webapplication

3. Use of Managed Path
Host-Header Site Collection : Yes
• Host-Header Managed paths are different from Path based managed paths and cannot be used for each other.
• Managed paths created for host-na…

Adding Custom Styles to Ribbon’s Styles dropdown

Image
Cool part about SP2010 is that as soon as it sees styles in the custom CSS file, it will add it to the Style dropdown, I made a quick documentation for a colleague so I thought would blog it as well.

You see the “Styles” in the Ribbon that is where I want to add my custom styles





This is a 2 step process:

1. All the custom styles in the custom css file should has the prefix .ms-rtestyle- and the value specified in the –ms-name: attribute will be displayed in the above dropdown



.ms-rteStyle-header {

-ms-name:"My Custom Header";

font-family: Calibri;

font-size: 19pt;

font-weight: normal;

color: #ef383f;

}



2. There are 2 ways to attach you Custom CSS file to the masterpage

Option 1 : Either specify the custom CSS file as an alternateCSS file by gong to CA\Site Settings\ Look and Feel\ Master Page ( you will have to activate the publishing feature for this option to be available)





OR

Option 2 : Just add a Link to the CSS file in the master page





Moving content using the granular “Perform a Site Collection Backup” option in SharePoint 2010

Image
Good part about it is that using this option everything within a site collection will be backedup including workflows!
Backup Process

Backup of the site collection can be done using CA but the restore has to be done using power shell command, I am going to take you step by step through both the backup and restore.

Click the “Perform a site collection backup” option and select the site collection that you want to backup



Enter the Location and filename where you want to backup and hit on “Start BackUp’ which will create a backup of the site collection

Restore Process
Login to the destination farm as a user that has permissions to run powershell and type the following cmdlt restore-spsite, below is the command that I ran to restore the site collection to my webapplication, using the force parameter in case there is already an existing sitecollection there:

Restore-spsite -identity http://mysharepointserver/ -path C:\databasename.bak -force

Creating site Collection in its own Database

Creating site collection form CA is one of the easiest things but creating it with its own database is a little different, there are several ways to do it but I am going to do it using powershell:

//Get the webapplication in $wb variable
$wb = Get-SPWebApplication -Identity http://MySharePointServer:9001

//Get the desired name of the site collection’s database, we will create this DB later
$dbname = “Wss_content_MySite”

//Get url of the desired site collection
$SiteCollectionUrl = “http:// MySharePointServer:9001/”

//Create the new database
new-spcontentdatabase $dbname -databaseserver "SP2010Database" -webapplication $wb

//Create the site collection
new-spsite –url $SiteCollectionUrl -owneralias MyDomain\OwnerOfSiteCollection -Contentdatabase $dbname

After this is done and the first time you login to the site collection you will be prompted to select the template for the site and the users.