Come join me for the first ever office 365 saturday in Redmond this Feb

That’s right, first ever Office 365 Saturday is taking place in Redmond this Feb.
I’ll be speaking on branding of Office 365 sites and you will also find many other innovative speakers

Here is the general info on the event:

Office 365 Saturday Redmond is an educational, informative & lively day filled with sessions from respected technology experts and community leaders, covering a wide variety of topics focused on Microsoft Office 365. Office 365 Saturday Redmond is FREE, open to the public, and is your local chance to immerse yourself in Office 365 including topics related to Exchange Online, Lync Online, and SharePoint Online.

Event website:
http://o365redmond.sharepoint.com

Attendee registration:
http://o365redmond.eventbrite.com/

See you there!

Posted in Event material | Tagged | Leave a comment

Unauthorized when using SharePoint PowerPivot document from Report Builder or Excel?

Here is the scenario: You’ve got WFE Server which is also an app server with PowerPivot set up, we’ll call it SPWFE. You also have the database server which is a SharePoint database, let’s call it SPDB. That same server hosts reporting services. Lastly you’ve got a 3rd database server hosting some data, let’s call it the LOBDataDB. So you have a PowerPivot workbook sitting in your SPWFE PowerPivot library, the data retrieved being retrieved from LOBDataDB. When you execute the workbook right from the PowerPivot library – the workbook renders no problem. When you use this workbook as a datasource to build the report in the ReportBuilder you get

The remote server returned an error: (401) Unauthorized

Here are the ground rules … you have to configure Kerberos authentication on:
-SPWFE, since it will be accessing data and passing credentials to other machines
-SPDB, well if SPWFE uses Kerberos, the DB server has to use it too
-LOBDataDB, needs to have Kerberos configured because SPWFE will be accessing information from it

For detailed instructions on how to configure Kerberos in each of the scenarios, search for this document which explains everything in details: Configure Kerberos Authentication for SharePoint 2010 Products

The solution:

So considering Kerberos is configured, you still need to ensure that PowerPivot uses Kerberos for it’s configurations.

On the SPWFE machine, access the following default folder for default PowerPivot installation:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\PowerPivot

Find the web.config, and locate the four nodes:

<transport clientCredentialType="Ntlm"/>

and replace the clientCredentialType attribute value to:

<transport clientCredentialType="Ntlm"/>

Now, under the customBinding node, locate the

<httpTransport manualAddressing="true"
authenticationScheme="Negotiate" transferMode="Streamed"
maxReceivedMessageSize="9223372036854775807"/>

and ensure the authenticationScheme is set to Negotiate as shown above.
Make this change for both custom bindings.

Now when you access the report server query builder and pass the PowerPivot datasheet as a data source, you should have no problem adding an entities.

Enjoy!

Posted in sharepoint, sharepoint 2010 | Tagged , , | Comments Off

Troubleshooting PowerPivot: Unable to refresh data for a data connection in the workbook

If you’re trying to explore one of the cool new integrations in SharePoint 2010 BI stack, PowerPivot, you might run into the problem where your PowerPivot workbooks will return the following error, when you try clicking on the slicer in your excel sheet in attempt to filter the data:

Unable to refresh data for a data connection in the workbook.
Try again or contact your system administrator.
The following connections failed to refresh
Data

Now, the first you might think – that the issue is related to the data refresh, and there is plenty on the internet related to the data refresh. The error is actually related to the PowerPivot not being able to access the data. The refresh capability is the ability to refresh workbooks automatically and has nothing to do with this error, in fact it will mislead you trying to troubleshoot the wrong issue.

If your SharePoint is running in a multiserver environment where your database is sitting somewhere else and your web front end sitting on another machine you might think that authentication has failed.
You may even think you need to install Kerberos, however …
The PowerPivot system is claims aware, and uses the Claims To Windows Token Service to recreate the client’s Windows identity using the client’s claims token in order to connect with the Analysis Service engine that runs on the application server.

Also Microsoft tells us:

When a PowerPivot workbook is uploaded in SharePoint Server,
it already contains the PowerPivot data that the workbook uses.
When the user opens the PowerPivot workbook in Excel Web Access and
interacts with the slicers, the PowerPivot System Service loads
the data in the workbook directly into its Analysis Services engine.
No access is made to the data connection embedded in the workbook.

However, if your PowerPivot workbook contains a data connection to a SQL Server instance that is linked to another SQL Server instance on a separate machine, you’ll need to configure Kerberos authentication with identity delegation for data refresh your data.

Check out how to configure Kerberos in this scenario using the doc here.

If you fall under the scenario where you don’t have distributed data stored on multiple servers and used in your PowerPivot workbook, then ensure the following:

You have installed SQL Server Analysis Services (PowerPivot) on your web front end machine.
When you navigate to Central Admin -> Services on this server, in the list of services on your web front end machine you see SQL Server Analysis Services (PowerPivot) is a started state.
If you don’t see it at all on the web front end server, you must install SQL Server Analysis Services (PowerPivot).
If you see it in the stopped state, try starting it again and refresh the page; if the service stops shortly after, the account which runs the service might have an expired password.

A simple way to verify that out of the box configuration works, navigate to Central Admin -> Manage Service Applications -> PowerPivot Service Application and ensure that PowerPivot Service Application dashboard shows its own system reports.

If you don’t see those, it’s a very high chance you won’t get your custom reports working.

Posted in sharepoint | Tagged , | Comments Off

Creating custom SharePoint site templates for the cloud

By this time you’ve probably had a chance to create SharePoinnt site templates for on-premises hosted environmenets. Learn how you can create new SharePoint 2010 site templates for cloud hosted environments such as office 365 etc. This will allow your users to create new instances of sites based on your custom definition.

Enjoy!

Posted in sharepoint | Tagged , , , | Comments Off

SharePoint branding with SharePoint Designer – screencast

If you’re involved in a SharePoint branding project and it’s a new topic for you, you’ll love this screencast which is going to go over tons of gotchas in about an hour :)
It was recorded recently and I`ve got some really good feedback on it, so I hope you`ll like it.

Enjoy!

Posted in sharepoint 2010 | Tagged , | Comments Off

How To: Create a reusable SharePoint web template in sandbox

If you’re working with a hosted SharePoint 2010 environment, any customizations you’re allowed to do are limited to sandbox solutions and artifacts compatible with sandbox solutions. This, of course, means you don’t have access to the file system; naturally nobody wants you to write files to the shared server environment.
That’s normally not a problem until you need to create web templates for your subsites.
Even when you’re provisioning a simple public site sitting in a cloud, you’d want to provision customized sub-sites to it.
To create new site and web definitions in on-premise hosted SharePoint – you would need to access the 14\Template\SiteTemplates on the file system.
Let’s take a look at how you can create web templates for the cloud-hosted solution.

I assume you have Visual Studio SharePoint 2010 project created with a sandbox option on.
Add a new feature to the Visual Studio solution, let’s call it ProvisionWebTemplates. Scope it to the SITE. This feature will provision our web templates.
Now add a new item to the project of type Empty Element.
Give it any name you like; this will be the name of your template, I’ll call mine AboutUs since I’m creating a template for About Us site.

Ensure that your newly created element is added to the ProvisionWebTemplates site feature.

You will get an Elements.xml file with your empty element solution item, this is going to be our web template declaration.
Replace the contents with the following:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <WebTemplate BaseTemplateID="1" BaseTemplateName="STS" BaseConfigurationID="1"
               DisplayCategory="My Category" Name="AboutUs" Locale="1033"
               xmlns="http://schemas.microsoft.com/sharepoint/" />
</Elements>

In here, the BaseTemplateID is the ID of the template for the base template, in my case a team site. Same goes for BaseTemplateName, which is the name of the base template, also a team site in my case. The rest is self explanatory. Here is more on other attributes and options available.

Now, add an onet.xml file to your AboutUs element folder. This is where our definition is going to be implemented, in terms of features activated and masterpages set etc.
So far our structure will look like this:

Ensure the deployment type for the onet.xml is set to ElementFile, otherwise the file will not be deployed to the proper location.

The contents of the onet.xml should look similar to below

<Project Title="My Template" Revision="0" xmlns="http://schemas.microsoft.com/sharepoint/">
  <NavBars>
  </NavBars>
  <Configurations>
    <Configuration ID="1" Name="AboutUs">
      <SiteFeatures>
      </SiteFeatures>
      <WebFeatures>
        <!--ProvisionPages-->
        <Feature ID="{327bb799-d491-4e6f-9a7c-fa4ba6300b2a}"
Name="FeatureDefinition/327bb799-d491-4e6f-9a7c-fa4ba6300b2a" />
      </WebFeatures>
    </Configuration>
  </Configurations>
</Project>

As you can see this web template definition doesn’t look any different from a site template definition in an on-premises scenario. In here, we define the name of the template and which features will be activated during the template provisioning. In our case, we activate only one feature which will provision pages to the site that was just created. You can of course activate any other features to set your masterpages etc.

That’s it. When deployed this project as a sandbox solution, you will be able to see an About Us web template available to create new sites from.

For more nifty automation tips, check out my SharePoint 2010 developer book.

Enjoy!

Posted in sharepoint 2010 | Tagged , , | Comments Off

.net BC usergroup presentation downloads

Thanks to everyone who attended the .net BC event today on Microsoft SharePoint Server 2010 for the Microsoft ASP.NET Developer. It was great to see you all and from what I hear you liked the session :)

There are few resources that I have thrown into the PowerPoint which should be helpful when you get started with SharePoint development.

Also, the name of the tool I recommend for Visual Studio development is called CKSDEV and can be downloaded by going to Tools -> Extension Manager -> Online Gallery in your Visual Studio 2010.

When installed you will be able to access handy project templates from within Visual Studio.
If you have any questions, drop me a note here on my blog and I’ll share those questions and answers with other.

Also, to create visual web parts in sandbox, download the Visual Web Part Sandboxed into your Visual Studio extension manager using the same approach as CKSDEV.

And here is the link to the PowerPoint.
.net UG presentation download

Links to my books are on the right ;)

Enjoy!

Posted in Event material | Tagged , | Comments Off

How To: Restrict visibility of SharePoint 2010 lists and libraries

Most users define which lists and libraries are there on the site by accessing All Site Content link.
This is how most users see their lists and libraries of the default SharePoint 2010 team site.

As you add more lists and libraries to the site, you can actually hide them from this view. This can be achieved pragmatically or using PowerShell.

Here is the sample code which is used to show a hidden library:

using (SPSite site = new SPSite("http://[servername]"))
   {
          using (SPWeb web = site.OpenWeb())
          {
              SPList solutionGallery = web.Lists["Solution Gallery"];
              solutionGallery.Hidden = true;
              solutionGallery.Update();
          }
   }

If you’re wondering what this library we have just made visible – it’s a Sandbox Solutions library; the place where users upload and manage sandbox solutions.
After running this code, the library will be visible along with all of the other lists and libraries.
In your example, you might want to hide lists and libraries which are used for your core customizations. It’s important to understand that this will not make the list inaccessible to users, permission management will need to be applied on the library to actually prevent users from accessing the library.
This functionality is for purely cosmetic purposes to reduce clutter on your site.

Once hidden, the list will not be visible to many other office applications such as SharePoint Designer. By the way, if you’re running SharePoint Designer, you can hide/un-hide a list by accessing it’s properties from within SharePoint Designer and selecting Hide this list from views

Enjoy!

Posted in sharepoint 2010 | Tagged , | Comments Off

How To: Set granular restriction on SharePoint 2010 Sandbox Solutions uploads

SharePoint 2010 sandbox solutions allow individual site collection owners to manage limited access solutions without involving administrators.
To manage sandbox solutions you’ve got to have the following permissions:

  • Manage Web
  • Manage Sub webs
  • Add and Customize Pages

If you delegate site collection administrator permissions to anyone – they will have all of the above permissions. Which may not be what you intend. After all, the fact that someone can create pages and manage webs doesn’t mean you want them to be able to upload custom sandbox solutions. For example you may want to limit the number of sandbox solutions uploaded to the gallery or block the upload of sandbox solutions on that particular site collection and allow them on other site collections.

If you want to establish central solution management policies and restrict your users with more granular policies, you can attach an event receiver on the solution gallery which holds all of the sandbox solutions.

Even though you access the solution gallery using the Site Settings page, as shown above, it’s just a specialized document library, which in fact has a Document Library as it’s base template.

We’ll start with creating a new Visual Studio 2010 SharePoint Project of Event Receiver solution template. You can use another project template as long as an event receiver is added to them later.
Ensure the project is a farm solution and from the receiver configuration wizard pick the options as shown below:

As you can see, our event receiver will run on new items (sandbox solution) being added, this way we can choose whether we allow a particular item or not.
Also, we have selected a custom list as our list template since Visual Studio doesn’t allow us to pick solution gallery by default. That’s ok, we’ll change this in a moment.

Once the project has been created, open the Elements.xml configuration file of the event receiver and set the ListTemplateID attribute value to 121, which is the ID of the solution gallery. This way our receiver will run events on the solution gallery and not on the custom list template as we’ve chosen earlier in the wizard.

Lastly, we need to write some code which represents our new solution upload policy. The code will go right into the event receiver class.
In my case, the code blocks the upload of any sandbox solution and shows a custom page to a user:

public override void ItemAdding(SPItemEventProperties properties)
       {
           base.ItemAdding(properties);
           properties.Cancel = true;
           properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
           properties.RedirectUrl = "_layouts/Project/SomeCustomErrorPage.aspx";
       }

Remember, since our custom project is a farm solution, it will run this code in each site collection. So with the code above, no-one will be able to upload sandbox solutions; you may want to be more specific with your custom policy.
That’s it, now you can deploy the event receiver project as you normally would.
To test, upload any sandbox solution into the solution gallery to get a custom or generic error message.

You’ll find more handy tips like this in my SharePoint 2010 dev book.

Enjoy!

Posted in sharepoint 2010 | Tagged , | Comments Off

How To: Extend SharePoint 2010 third party or legacy webparts in your solution

Since the title of this post doesn’t really do justice, let’s take a look at a few scenarios.

Scenario 1. You have a third party webpart and would like to alter it’s execution flow as much as it permits through public properties and methods.

Scenario 2. You have a legacy webpart and no source code; you would like to use a legacy webpart as a main part and add a few extra components and render them all as one webpart.

Since each SharePoint webpart inherits from System.Web.UI.WebControls.WebParts, requiring it to have a default constructor, you can render a webpart as part of another webpart in few simple steps.

We’ll start with creating a new Visual Studio 2010 SharePoint Solution and for template choose a Visual WebPart Project. Let’s call this project HostWebpart so it’s clear as we go along.

We’ll also need another webpart to which will be hosted within HostWebpart. Whether it’s one of your own webparts or a third party webpart, it doesn’t matter. You can download a free webpart you can use for testing from codeplex. This web part will be hosted within out HostWebpart. Well call it a Hosted Part.

Depending on the complexity of your Hosted Part, if it uses external resources such as CSS and controls, you will need to deploy the WSP first so all of the dependencies are in place.

Next, navigate to your portal and add a Hosted Part to the page. Once added, export the webpart declaration as shown below:

Save the file and open it in Notepad. The top part will show you the assembly name and the type we’ll reference later.
Here is the sample I have exported.

<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name="Microsoft.SharePoint.Publishing.
           WebControls.ContentByQueryWebPart,
           Microsoft.SharePoint.Publishing, Version=14.0.0.0,
           Culture=neutral, PublicKeyToken=71e9bce111e9429c" />

Since in my case, I’ve used out-of-the-box webpart, the Content by Query Webpart, my assembly is Microsoft.SharePoint.Publishing and the type name is Microsoft.SharePoint.Publishing. WebControls.ContentByQueryWebPart. In your case, remember those items, we’ll reference them in just a bit.

In your HostWebpart Visual Studio project, reference the assembly in the DLL References. Even though our HostWebpart is already deployed, we need a DLL reference so we can create an instance of it in the HostWebpart.

Now we can create an instance of the Hosted Part right within our Visual WebPart project (the HostWebpart). Open the code behind of the user control for your Visual WebPart (VisualWebPart1UserControl.ascx).

In the Page_Load event, create an instance of your Hosted Part by calling it by type you’ve recorded earlier, in my case I would define my Hosted Part like this:

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace VisualWebPartProject1.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart cqwp =
                new Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart();

            cqwp.ChromeType = PartChromeType.None;
            // any other public properties or methods can be called in here
            this.Controls.Add(cqwp);
        }
    }
}

Notice how I set the ChromeType property of the Content by Query Webpart. Well, this will ensure the border around it is not displayed and it will appear as it’s part of the HostWebpart.
In the actual ASCX control representing the Visual Webpart, you can add any elements you require, they will all render along with the Content by Query Webpart just as they were a single webpart.
Notice how we added our Content by Query Webpart to the main set controls:

this.Controls.Add(cqwp);

Well, if you like, you can add it to another control such as a panel or a repeater etc. This way you can control it’s rendering if required. Just add the panel or another component to your Visual Werbpart and then you can start adding Controls to it.

Of course, in this approach you’re limited to public properties of the Hosted Part in terms of altering its execution flow; but in many scenarios that’s all you need.

Try it out with a third party webpart!

Posted in sharepoint, sharepoint 2010 | Comments Off