Archive for May, 2013

Publishing Sites Without Workflows

Let me start by saying I HATE publishing sites. Sure they are great for branding and such but they are a pain on so many levels.

However, that’s what we use as our baseline site collection. Recently, I created a new site collection as a publishing site and it decided it needed a workflow to run when you decided to publish the site. We didn’t want that since the designers were just modifying the page and it was a laborious process to go through the workflow. So how do you disable this? Pretty easy, actually!

Navigate to the Pages library (View all site content for example). Click on the Library tab then Library Settings. Under General settings, click on Versioning settings. For “Require content approval for submitted items?” select the No radio button. That’s it!

You can go to Workflow settings and delete the workflow if you want but it’s not necessary.

, , , , , , , , , , , ,

Leave a comment

PNG files not showing in SharePoint 2010

One of our users made a discovery that was brought to my attention. Actually, it was two issues, if you could call them that. First, they reported that when they upload a .png file, it gets converted to a .jpg file. Second, the .png files were not showing up and giving the infamous red X.

Let’s start with issue number 1. This is by design in SharePoint 2010.

SharePoint automatically creates two JPG images every time you upload image to a Picture Library: they are the thumbnail image and the web preview image. They’re stored along with the original image in the Picture library.

No in-place conversion happens: the image is converted only once during the initial upload process.

SharePoint needs these extra images to display picture library thumbnail views and item forms correctly, quickly and not causing excessive server load. However, when you add the image to a page or image web part, it actually displays the .png file. So no conversion, no problem.

Now on to issue number 2. You upload a .png file to picture library. The thumbnail looks great, the preview image looks great, you copy the link and open it in a new tab and you get the big, fat, red X.

This is all because of the color profile of the image. If the web designer used PhotoShop or some other similar application, they may have saved the image with a CMYK color profile. Browsers can’t display CMYK images. Thus, the red X. The thumbnail and the preview are .jpg files (see above) so they look fine.

To solve the issue, just open up the image in your choice of editing software and save it as an RGB image. Re-upload the file and everything is fine!

, , , , , , , , , , , , , , , , , , ,

1 Comment

Changing the Top Bar color in SharePoint 2013/Office 365

In SharePoint 2010 and 2007 it was a simple task to change the colors and create your own theme for a SharePoint site. Just open the master page, find the proper CSS tag and change the color. But with SharePoint 2013, the themes or Composed Looks are abstracted from SharePoint as much as possible. This is wonderful if you have a designer who only knows HTML, CSS, and the lot. Even SharePoint Designer 2013 no longer has the Design view and leaves you with the code. The idea is to allow the web designer to use whatever tools they are use to and not have to learn SharePoint or SharePoint Designer. This is going to make for some amazing sites that look nothing like Out-Of-The-Box SharePoint sites! (How many times has your customer requested that you make it look not so “SharePointy”?)

I had a customer who wanted a SharePoint extranet and didn’t mind if it looked like SharePoint. All they wanted was the colors to match their logo. Instead of creating a new Composed Look (which I will do when the crunch is over), I simply wanted to change the colors a bit. The easiest way is to apply a theme that is close to what you want and just modify the palette.spcolor file for that theme. Another upside is that it will cascade down to your sub-sites as well. Let’s get started!

The first thing we want to do is apply a Composed Look that is similar to what we want. In this case, the customers logo was green so I picked, you guessed it, the Green theme. This is what the site looked like with the logo. Note that it is a different shade of green than the theme’s green.

Capture2

Now I wanted to change all the greens to match the logo color. First step is to open the logo in Paint and use the eye dropper tool to get the color and then convert it to hex with the Calculator. This came out to be: 00703c. The next step is to find the palette.spcolor file that is associated with the current theme. These palette files are what are referenced from the Colors drop down on the Change the Look page. Go to Site Settings and under Web Designer Galleries, pick Composed Looks. If you scroll to the bottom of the page you will Current as in Current theme. Make note of the palette file name. In this case, palette13.

Capture1

Go back to Site Settings and under Web Designer Galleries, pick Themes. Go to the 15 folder and there you will see all the palette files. We want to modify palette13 so click the Files tab and then the Dowload a Copy icon. Save it to you local box. I usually make a copy, too, and call it palette13_old, just in case. While your here, check out the palette13 file.

Capture3

Capture4

Open your local copy of the palette13 file and start looking. It’s somewhat similar to the old CSS files from SharePoint 2007 and most of the fields make sense. What I did was deduce which values were green which turned out to be 339933 and replaced them all with 00703c. For reference, the Office 365 bar is called Suite Bar in the palette file. Once you are done editing the file, save it and re-uploaded it to the Themes page. Be sure to check it in.

Capture5

Finally, go Site Settings and under Look and Feel, select Change the Look. Re-apply the current them or otherwise nothing will change. Do the same for any sub-sites as needed.

There you have! The quick and dirty way to change the colors in SharePoint 2013. Obviously, it’s better if we create a proper Composed Look which I will go over in detail in a future post. But for now, this will work if only minor changes are needed.

, , , , ,

3 Comments

Create a Site Collection in a new Content Database with PowerShell

Creating a SharePoint site collection has always been a pain. Especially if you do it properly so that there is only 1 site collection per content db. In the past, we always used stsadm but with the improvements in PowerShell, it can be done without much user intervention.

My goal was to create a PowerShell application that would only prompt for the bare requirements to build a new site collection. The long term goal is to add an interface so that site managers (essentially power users) can manage all this themselves. Personally, I think this would make a great SharePoint 2013 app which could be easily accomplished with NAPA.

What we did was create a site collection baseline. This is just a site that we will base all our site collections on. It has all the custom templates, list/libraries, branding, and so forth. That being said, let’s step through the code!

The first step is to gather the required information for the new site collection, create a new content db, and create the site collection. We are not adding a template because we will be importing the baseline site collection for that.

$ErrorActionPreference = “Continue”;

#Get input from user
$name = Read-Host “Enter New Site Collection Name”; #Prompts for Site Title (you can change this later)
$site = Read-Host “Enter New Site Collection URL”; #Prompts for your new site collection URL (https://url.webapp.com/sites/newsitecoll for example)
$dbname = Read-Host “Enter Content Database Name”;

#Default values, change to your values
$owner1 = “domain\owner1”;
$owner2 = “domain\owner1”;
$server = “MY_CONTENT_DB_ALIAS”; #This is the alias you setup to your database server. You did do that, right?
$webapp = “https://url.webapp.com”; #This is the root URL to your web app

#Create content db
Write-Host “Creating Content DB”
New-SPContentDatabase -Name $dbname -DatabaseServer $server -WebApplication $webapp
Write-Host “Content DB Created Sucessfully”

#Create the site collection
Write-Host “Creating Site Collection $site”
New-SPSite -URL $site -OwnerAlias $owner1 -SecondaryOwnerAlias $owner2 -ContentDatabase $dbname
Write-Host “Site Collection $site Created Sucessfully”

#Set the content db so it will only contain 1 site collection
Get-SPContentDatabase -Site $site | Set-SPContentDatabase -MaxSiteCount 1 -WarningSiteCount 0
Write-Host “Set Content DB to only contain 1 Site Collection”

At this point we have a new site collection so we are going to export the baseline site collection and import it into the new site collection. I do a fresh export every time in case the users have made changes.

#Export baseline site collection
Write-Host “Exporting New Baseline Site Collection”
export-spweb -identity https://url.webapp.com/sites/extranetbaseline -path d:\backup\baseline\baseline.cmp -force -includeusersecurity
Write-Host “Exported Baseline Site Collection Sucessfully”

#Import the baseline site to the new site collection
Write-Host “Importing Baseline into new Site Collection”
Import-SPWeb -Identity $site -Path d:\backup\baseline\baseline.cmp -includeusersecurity -force
Write-Host “Baseline Imported Sucessfully”

At this point we have a new site collection that is identical to the baseline site collection. My customer wanted to delete some of the default security groups. So the code below will do just that. You can either not use this or change it as needed.

#Delete the unwanted default groups
Write-Host “Deleting Site Groups”
$web = get-SPWeb $site

$objSiteGroup = $web.SiteGroups[“Designers”]
$web.SiteGroups.Remove(“Designers”)
Write-Host “Designers Deleted”

$objSiteGroup = $web.SiteGroups[“Hierarchy Managers”]
$web.SiteGroups.Remove(“Hierarchy Managers”)
Write-Host “Hierarchy Managers Deleted”

$objSiteGroup = $web.SiteGroups[“Approvers”]
$web.SiteGroups.Remove(“Approvers”)
Write-Host “Approvers Deleted”

$objSiteGroup = $web.SiteGroups[“Style Resource Readers”]
$web.SiteGroups.Remove(“Style Resource Readers”)
Write-Host “Style Resource Readers Deleted”

Now comes the fun part. They also wanted to add their group to site collection administrators. As simple as that sounds, the SharePoint team didn’t plan for that. On top of this, we are using claims based authentication which has no groups. Otherwise, I would just put in the AD group and be done with it. Below is a the more long winded approach.

#Add additional users as site collection administrators
$sp_web = Get-SPWeb $site

#Add first user
$Account=”domain\user1″
$Email = “user1@domain.com”
$sp_web.AllUsers.Add($Account, $Email, “”, “”)
$user = Get-SPUSER -identity $Account -web $site
$user.IsSiteAdmin=1
$user.Update()

#Add second user
$Account=”domain\user2″
$Email = “user2@domain.com”
$sp_web.AllUsers.Add($Account, $Email, “”, “”)
$user = Get-SPUSER -identity $Account -web $site
$user.IsSiteAdmin=1
$user.Update()

Write-Host ” “
Write-Host “Site Collection at” $site “has been created in the” $dbname “content database” -ForegroundColor Yellow

That wraps it up. If you need to add anything to this script, just leave me a comment. Next time you see this, it will be 2013 App!

Here’s the whole script for you to copy and paste. Just save it as a .ps1 file and run it as a farm account:

$ErrorActionPreference = “Continue”;
#Get input from user
$name = Read-Host “Enter New Site Collection Name”;
$site = Read-Host “Enter New Site Collection URL”;
$dbname = Read-Host “Enter Content Database Name”;

#Default values
$owner1 = “domain\owner1”;
$owner2 = “domain\owner2”;
$server = “MY_CONTENT_DB_ALIAS”;
$webapp = “http://my.rootwebapp.com”;

#Create content db
Write-Host “Creating Content DB”
New-SPContentDatabase -Name $dbname -DatabaseServer $server -WebApplication $webapp | out-null
Write-Host “Content DB Created Sucessfully”

#Create the site collection
Write-Host “Creating Site Collection $site”
New-SPSite -URL $site -OwnerAlias $owner1 -SecondaryOwnerAlias $owner2 -ContentDatabase $dbname | out-null
Write-Host “Site Collection $site Created Sucessfully”

#Set the content db so it will only contain 1 site collection
Get-SPContentDatabase -Site $site | Set-SPContentDatabase -MaxSiteCount 1 -WarningSiteCount 0
Write-Host “Set Content DB to only contain 1 Site Collection”

#Export baseline site collection
Write-Host “Exporting New Baseline Site Collection”
export-spweb -identity http://my.rootwebapp.com/sites/baseline -path d:\backup\baseline\baseline.cmp -force -includeusersecurity
Write-Host “Exported Baseline Site Collection Sucessfully”

#Import the baseline site
Write-Host “Importing Baseline into new Site Collection”
Import-SPWeb -Identity $site -Path d:\backup\baseline\baseline.cmp -includeusersecurity -force
Write-Host “Baseline Imported Sucessfully”

#Delete the unwanted default groups
Write-Host “Deleting Site Groups”
$web = get-SPWeb $site

$objSiteGroup = $web.SiteGroups[“Designers”]
$web.SiteGroups.Remove(“Designers”)
Write-Host “Designers Deleted”

$objSiteGroup = $web.SiteGroups[“Hierarchy Managers”]
$web.SiteGroups.Remove(“Hierarchy Managers”)
Write-Host “Hierarchy Managers Deleted”

$objSiteGroup = $web.SiteGroups[“Approvers”]
$web.SiteGroups.Remove(“Approvers”)
Write-Host “Approvers Deleted”

$objSiteGroup = $web.SiteGroups[“Style Resource Readers”]
$web.SiteGroups.Remove(“Style Resource Readers”)
Write-Host “Style Resource Readers Deleted”

#Add additional users as site collection administrators
$sp_web = Get-SPWeb $site

#Add first user
$Account=”domain\user1″
$Email = “user1@domain.com”
$sp_web.AllUsers.Add($Account, $Email, “”, “”)
$user = Get-SPUSER -identity $Account -web $site
$user.IsSiteAdmin=1
$user.Update()

#Add second user
$Account=”domain\user2″
$Email = “user2@domain.com”
$sp_web.AllUsers.Add($Account, $Email, “”, “”)
$user = Get-SPUSER -identity $Account -web $site
$user.IsSiteAdmin=1
$user.Update()

Write-Host ” “
Write-Host “Site Collection at” $site “has been created in the” $dbname “content database” -ForegroundColor Yellow

, , , , , , , , , , , ,

12 Comments

Interesting Article: Great SharePoint Interview Questions – What they should ask, what you should say

http://news.dice.com/2013/05/02/interview-questions-sharepoint-architects

I heard a new term today from one of our SharePoint site managers:

PICNIC – Problem In Chair, Not In Computer

, , , , ,

Leave a comment

Getting a list of sites that a user has access to in SharePoint

My customer needed a way to show all the sites and site collection where the user had access. This is for an extranet which we decided would be driven off the MySites. The idea is that the user logins in and is directed to their MySite. There they would see a list of all their sites and can navigate from their. You would think somebody would have built a web part by now but if they have, I couldn’t find it!

So I came up with the idea of using the search results web part and contentclass managed property. Since SharePoint security trims everything for you, it was simple to get a list of sites. Well, there was a bit of head banging as usual. But the results are pretty sweet!​

The contentclass managed property is a property that means something to the SharePoint search. You can think of them as search scopes but they can be added directly into the search query box. For example, go to your SharePoint site and enter this into the search: contentclass:”STS_Web” and hit search. The search results will be all the sites in the web app. You might notice that none of the root web site for the site collections are displayed. Just add STS_Site and you get the root sites. You can simply combine the parameters as such:

contentclass:”STS_Site” contentclass:”STS_Web”

Now comes the fun part. We are going to use the Search Results web part to add the list of sites to the page. Simply add a Search Results web part to your page and edit the web part properties. Add the contentclass parameters to the search query.

search_results_web_part_config

Because of security trimming, the logged in user will only see their sites.

search_results_web_part

Now you can go in with SharePoint Designer and modify the XSLT to make things look a little nicer. I’ll go into that in a future post. Until then here are some links to using the contentclass managed properties:

http://blog.slalom.com/2010/04/07/sharepoint-2010-search/

http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/07/20/some-handy-keywords-you-might-find-useful-in-sharepoint-enterprise-search.aspx

, , , , , , , , ,

2 Comments

SharePoint 2010 Search Lockup

I just got through building a HUGE extranet for one of my clients. Since it hosts a large number of customers from different companies, the security requirement was to limit them to only the sites they have access granted. We decided to drive the users off the MySites and I created a custom web part to show all of the sites they were members of (I’ll blog on how I did that later). The key was it used the search and security trimming to work.

Now here’s what happened. Everytime I ran a full crawl,​ the search query component locked. This caused my web part to throw one of those lovely correlation error messages. No luck checking through the ULS logs. It just stopped and no amount of turning the service on and off or an IIS reset would work.

As a last ditched effort, I rebooted WFE. No problem since I have 2 and they are load balanced. Low and behold! It worked!

Now both the WFEs are in a DMZ and locked down at the firewall. That just doesn’t seem like it would be the issue though. A Microsoft buddy of mine admitted that it was one of those rare and known bugs.

So there you go. You know what they say: “When in doubt, reboot!”

, , , , , , , ,

3 Comments