You are on page 1of 31

RunWithElevatedPrivileges

- Suppose you have written a piece of code that will add an item to a SharePoint list. But suppose
a user has only read access to the site then s/he will get the access denied error when try to
execute the code. But still you can run the code by calling the RunWithElevatedPrivileges
method provided by the SPSecurity class.
- The SPSecurity class exposes a method called RunWithElevatedPrivileges, which gives you an
option to elevate the privilege to the application pool identity under which your code is
executing.

- Syntax:
SPSecurity.RunWithElevatedPrivileges(
delegate()
{
// Code will go where
}
);

- Elevated privilege can be used to bypass or work with security.

Here are some points to follow while working with RunWithElevatedPrivileges.

- Avoid using SPSecurity.RunWithElevatedPrivileges to access the SharePoint object model.
Instead, use SPUserToken to impersonate SPSite with a specific account, as shown previously.

- If you do use SPSecurity.RunWithElevatedPrivileges, dispose of all objects in the delegate. Do
not pass SharePoint objects out of the RunWithElevatedPrivileges method.

- Only use SPSecurity.RunWithElevatedPrivileges to make network calls under the application
pool identity. Dont use it for elevation of privilege of SharePoint objects.

If you run code with elevated privileges and you create new objects, such as list items within a
list, the user automatically assigned as author or editor is SHAREPOINT\system.

Here is an example that will add an item to a SharePoint list.

try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite myTopSite = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb myTopWeb =
myTopSite.OpenWeb(SPContext.Current.Site.RootWeb.ID))
{
myTopWeb.AllowUnsafeUpdates = true;

SPList listMyList = myTopWeb.Lists.TryGetList("MyList");

SPListItem newItem = listMyList.Items.Add();
newItem["Title"] = "Item 1";
newItem["Description"] = "This is item 1";
newItem.Update();
myTopWeb.AllowUnsafeUpdates = false;
}
}
}
});

}
catch (Exception ex)
{

}


What Makes Up SharePoint Branding?
Strategies used to implement SharePoint branding include, but are not limited to, master pages,
page layouts, and Cascading Style Sheets (CSS).
Master pages are used to identify the shared elements throughout your site. Examples of shared
elements include logos, navigation menus, and footers. Master pages provide the consistency
needed to create cohesiveness throughout all the pages in your site, in your site collections, or
both.
Page layouts provide a powerful and flexible way to manage the overall look and feel of your
site's pages. They also provide the control that you need to manage the type of subject matter that
can be created on any given page while still giving users the freedom to create their own content.
Page layouts are instrumental in providing content organization and consistent brand awareness.
CSS is used to control the overall display of page elements, including imagery, fonts, layouts,
and page structure. To adjust the look and feel of your SharePoint site, SharePoint 2010
primarily uses CSS. In fact, SharePoint 2010 requires that designers understand CSS to a much
greater degree than in earlier versions of SharePoint. My favorite CSS resource is CSS: The
Missing Manual (OReilly Media) by David Sawyer McFarland. For a more general SharePoint
2010 resource, I recommend Professional SharePoint 2010 Branding and User Interface Design
(Wrox Press). This book does a great job of explaining SharePoint branding concepts, including
reasons for using certain techniques to brand SharePoint sites.
Let's Get Started
The fictitious site that we'll be using as an example throughout this article is The Playbook. The
Playbook is an intranet site that was created for football coaches at a local high school. The
coaches don't need an extensive amount of branding, but they want a look and feel that
represents their high schools color scheme.
This branding example is based on a SharePoint Server 2010 publishing site. The out-of-the-box
Welcome Blank Web Part page layout was applied to the home page. Because we're not going to
create a completely custom look and feel, the out-of-the-box master page and one of the out-of-
the-box page layouts are sufficient for this project. Primarily, we need to change the logo and the
color scheme. Figure 1 shows what the end result will look like.
To begin, let's apply the out-of-the-box master page that we're going to use for this project to the
SharePoint site. To change the master page (as shown in Figure 2), follow these steps:
1. On the Site Actions menu, click Site Settings.
2. On the Site Settings page, in the Look and Feel section, click Master Page.
3. In the Site Master Page section, click Specify a master page to be used by this site and all
sites that inherit from it.
4. In the list, click v4.master.
5. Click OK.
Notes:
The site master page is used by all publishing pages.
The system master page is used by all pages in nonpublishing sites and by all
corresponding forms, views, and settings pages.
Select and Apply Themes
After we set the Master Page, we can move on to modifying the color scheme for the site.
Typically, the first thing I do is decide which out-of-the-box theme looks the closest to the brand
that I'm creating. Why spend time styling Web Parts and lists to match our color scheme when
we can let SharePoint do this work for us? For our The Playbook intranet site, we decide that the
Mission theme best matches our color scheme.
To change the theme, follow these steps:
1. On the Site Actions menu, click Site Settings.
2. On the Site Settings page, in the Look and Feel section, click Master Page.
3. Select the Mission theme.
For this example, the out-of-the-box Mission theme is sufficient, as Figure 3 illustrates.
However, in many cases, you must use a custom theme. I won't discuss how to create a custom
theme in this article because my husband, Todd Baginski, has a great blog post that describes
how to do it. See his topic, "HOW TO: Create a custom theme for SharePoint 2010."
After we apply the Mission theme to the SharePoint site, your site will look like what you see in
Figure 4.
As I mentioned earlier, applying the Mission theme affects the style of all the lists, Web Parts,
and administration pages on the SharePoint site. However, we still have work to do to
completely brand the site and make it look the way the client wants.
Change the Logo
The next step is to change the sites logo image. To do this, open SharePoint Designer 2010.
We'll keep SharePoint Designer 2010 open for the remaining tasks in this article. To open
SharePoint Designer 2010, click Start, click All Programs, click SharePoint, and then click
Microsoft SharePoint Designer 2010.
If this is the first time that you have opened SharePoint Designer 2010, you won't see any sites
listed in the Recent Sites section (Figure 5). If this is the case, click Open Site, and then type the
URL of the SharePoint site in the Site Name box.
The Site Settings page opens, and you see the navigation pane on the left side. The new logo is
located in the SiteCollectionImages folder. This folder was created via the Publishing feature,
and it is a common folder for storing images that you want to use throughout your site collection.
To open the SiteCollectionImages folder, click All Files, and then click SiteCollectionImages in
the navigation pane (as shown in Figure 6).
On the Ribbon, click Import Files (as shown in Figure 7), and then upload your new logo.
Note: A helpful feature is the ability to pin a gallery. This opens up a mini-gallery below the
navigation pane. To pin a gallery, move the mouse pointer over the link that you want to pin. In
this example, move the pointer over the All Files link. Then, when the pin icon appears, click it.
This gallery will be displayed even if you browse to another gallery (as in Figure 8).
After the logo image is uploaded to the SharePoint site, configure the site to display the new logo
(as shown in Figure 9). To do this, follow these steps:
1. On the Site Actions menu, click Site Settings.
2. On the Site Settings page, in the Look and Feel section, click Title, description, and icon.
3. In the Logo URL field, type /sitecollectionimages/youLogo.png.
If you decide to store your logo on the servers file system instead of in the content database, the
URL location is /_layouts/images/logo.png.
Create and Apply CSS
We'll use CSS to complete the look and feel of the site. It's never a good idea to edit the styles in
the Corev4.css file. Instead, override the default SharePoint styles by using a custom CSS file
and ensure that this file is loaded after the core CSS. There are two ways that we can do this; we
can specify a custom CSS file via the master page, or we can use the Alternate CSS option.
Because this is a simple branding project and we're not modifying master pages, we'll use the
Alternate CSS option.
The Alternate CSS option lets you apply custom CSS to a site and its subsites. This option is
available only from the SharePoint web user interface within a SharePoint server publishing site.
The Alternate CSS option also ensures that this CSS file will load last, which prevents the
Corev4.css from overriding it.
First, let's create our custom CSS file in SharePoint Designer. To do this, follow these steps:
1. In the navigation pane, click All Files, click Style Library, right-click the Style Library
folder, click New, and then click Folder.
2. Name your folder Playbook.
3. Right-click the Playbook folder, click New, and then click CSS.
4. Right-click your new CSS file, and then rename it as playbook.css. Figure 10 shows the
result.
To use the Alternate CSS option, follow these steps:
1. In SharePoint, on the Site Actions menu, click Site Settings.
2. On the Site Settings page, in the Look and Feel section, click Master Page.
3. Click the Specify a CSS file to be used by this publishing site and all sites that inherit from
it option.
4. In the text box, type /Style Library/playbook/playbook.css (as Figure 11 shows).
Now we're ready to start modifying our CSS file. There are two tools that I often use to find
SharePoint classes to override: Internet Explorer 8 (IE 8) Developer Tools and Firebug for
Firefox. These are two must-haves that will make your experience with branding SharePoint so
much easier! When I begin any SharePoint project, I always make sure that IE, Firefox, and their
corresponding tools are open and ready to use.
Notes:
Developer Tools are included with IE 8. To activate them, click Tools, then click
Developer Tools.
Firebug is a third-party add-on for Firefox. You can download here.
So far (see Figure 12), we have added only the Mission theme and our custom logo to the site.
Now we're going to go back to the custom CSS file created in SharePoint Designer and start
adding our CSS.
To edit the Playbook.css file, follow these steps:
1. In the navigation pane, expand Style Library, and then expand Playbook.
2. Right-click playbook.css, and then click Edit File in Advanced Mode (as Figure 13 shows).
If the file is not already checked out, you will be prompted to check out the file before editing.
Your blank CSS file is now open and ready for editing. I personally prefer to begin editing my
CSS from the top down, so we'll use that method here. It's also a best practice to comment your
code beginning with /* and ending with */.
Follow these steps to edit the CSS file:
1. The background color of the Ribbon isnt what we want, so let's change that first. Apply the
following CSS class to modify the background color of the Ribbon. After you apply the
following CSS class, the background changes to a green color instead of the brownish color that
was applied by the Mission theme.

body #s4-Ribbonrow {

background-color:#283A10;

}
2. We could use a repeating background image to change out the header, but let's use CSS
instead to change the height of the header and to create a gradient visual filter. Apply the
following CSS class to set a vertical gradient that starts with a light green and ends with a darker
green:

.s4-title {
height:125px;
filter:
progid:DXImageTransform.Microsoft.gradient(startColorstr='#C3D6A
A', endColorstr='#283A10'); /* for IE */
background: -moz-linear-gradient(top, #C3D6AA, #283A10); /* for
firefox 3.6+ */
}
3. We need to change the breadcrumb in the title area. The breadcrumb (shown in Figure 14)
includes site and page titles as well as the names of list views. Apply the following CSS class to
change the color value, the font-variant value, and the font-weight value of the site title in the
header area (the first title breadcrumb):

.s4-title h1 a {
color:#1E4620;
font-variant:small-caps;
font-weight:bold;
}
4. Change the color of the page title in the header area (the second title breadcrumb). To do
this, apply the following CSS class:

.s4-title h2 a {
color:#383838;
}
/* Team Site*/
.ms-WikiPageNameEditor-Display {
color:#383838;
}
/*Blog Site*/
.s4-titletext h2 {
color:#383838;
}
5. The following CSS class changes the color of the list view name that follows the page title
in the header area (the third-level breadcrumb).

.ms-ltviewselectormenuheader .ms-viewselector a,.ms-
ltviewselectormenuheader .ms- viewselectorhover a {
color:#383838;
}
Note: To see a sample of a list view name, click the title of a Web Part. (Figure 15 shows the All
Documents view in the breadcrumb, and Figure 16 shows the list view name.)
6. On the Site Actions menu, click View All Site Content. You'll notice some descriptive text
underneath the breadcrumb, which Figure 17 shows. This color was dictated by the theme, but
it's too hard to read. Well apply the following CSS class to change it:

.s4-title .s4-pagedescription,.s4-title .s4uniqpermdescription {
color:#CCCCCC;
}
7. The social icons don't match the brand, so we'll apply the following CSS class to change the
horizontal border that appears to the left of the social icons, font, and rollovers. Figure 18 shows
the social icons after the custom CSS is applied.

.ms-socialNotif-groupSeparator {
border-right:1px solid #146835;
border-left:1px solid #1E4620;
}
.ms-socialNotif-text {
color:#19361A;
}
.ms-socialNotif:hover {
border:1px solid #1B9747;
background-color:#4BB749;
}
8. The top navigation (also referred to as global navigation) must match our brand. Therefore,
we'll apply the following CSS class to add padding on the top and bottom of the links. By doing
this, we create a new look and we format the text links.

body #s4-topheader2 {
min-height:35px;
border-bottom:5px solid #E9EFE1;
}
.s4-toplinks a {
margin-top:5px;
}
.s4-toplinks .s4-tn a.selected {
border-color:#8EA86C;
border-top-color:#C3D6AA;
background:none;
background-color:#ECF2E4;
margin:5px 5px; /* Added Margin Top Only */
}
.s4-toplinks .s4-tn a.selected:hover {
color:#003759;
}
.s4-toplinks .s4-tn a {
color:#003759 !important;
}
9. We need to modify the search area to line up with the new formatting of the top navigation.
To do this, apply the following CSS class:

.s4-search {
margin-top:5px;
}
10. Out of the box, SharePoint displays a publishing status bar on a yellow background, which
you can see in Figure 19. For this project, I chose to remove it. We could remove it from the
master page, but because we're not editing master pages, we can apply the following CSS class
to remove it.

#s4-statusbarcontainer {
display:none;
}
11. We have to style the Quick Launch (also known as left navigation) to match our overall look
and feel. We'll apply the CSS class that is shown in Listing 1 to change the background color, the
containing borders, and the individual formatting of the links.
Note: To decrease download time, it's a best practice to combine styles instead of listing them
individually. For example, the following CSS class shows the individually-listed styles:

body #s4-leftpanel-content {
background-color:#F2F7EB;
border:solid #E9EFE1;
border-right-width:5px;
border-bottom-width:5px;
border-left-width:5px;
}
To combine the styles, well use the following CSS class:

body #s4-leftpanel-content {
background-color:#F2F7EB;
border:solid #E9EFE1 0 5px 5px 5px;
}
However, if you dont like the result, write out the styles exactly the way SharePoint had listed
them to begin with.
12. Out-of-the-box, the Quick Launch displays the View All Site Content and Recycle Bin links
below the Quick Launch links. Clients often ask me to remove these two links, so I've decided to
remove them on this project. Note: We could remove these links by using a custom master page,
but because we're not customizing a master page, we'll apply the following CSS class:

.s4-specialNavLinkList {
display:none;
}
13. Lastly, we'll change the formatting of the Web Part title text by applying the following CSS
class:

.ms-WPTitle, .ms-WPTitle a, .ms-WPTitle a:visited, .ms-WPHeader
a:active {
color:#297939;
font-weight:bold;
}
Now that you've finished editing your CSS file, be sure to check it in and publish it as a major
version so everyone else can see your changes. After you check in and publish your changes, you
can refresh the web browser and see that your site looks just like Figure 1.
Looking Forward
As you have now seen, you can easily create a custom look just by adding one image, making a
few CSS changes, and applying an out-of-the-box theme. As you click through the site, you'll
notice that all the elements in the site are branded consistently, including the Site Actions drop-
down menu rollovers, the Web Parts, and the administration pages. Using the out-of-the-box
theme saves a lot of time and effort with branding many of these elements in the SharePoint site.
To locate all of the CSS styles I modified in this project, I used the IE 8 Developer Tools and
Firebug. In my next article, we'll talk about custom branded master pages.

Listing 1: Styling the Quick Launch
body #s4-leftpanel-content {

background-color:#F2F7EB;

border:solid #E9EFE1;

border-right-width:5px;

border-bottom-width:5px;

border-left-width:5px;

}

.s4-ql ul.root > li > .menu-item, .s4-qlheader, .s4-
qlheader:visited {

color:#1E4620;

font-variant:small-caps;

font-weight:bold;

}

.s4-ql ul.root ul > li > a {

color:#3B4F65;

}

.s4-ql ul.root ul > li > a:hover {

color:#3B4F65;

}

.s4-ql a.selected {

background:none;

background-color:#E0EAD0;

}

SharePoint 2007 and 2010 have numerous differences. When I first started branding for
SharePoint 2010, I began making a list of branding tips to share with the students in my branding
courses. In this article, Ill share some of the tips that my students and I have found most useful.
SharePoint Designer Tips
If you spent any time at all working with SharePoint Designer 2007 and then moved on to
SharePoint Designer 2010, you noticed right away how radically different the 2010 interface is.
These SharePoint Designer tips will help simplify your work with SharePoint Designer 2010.
Tip 1: Change the content type of your master page to Publishing Master Page. My first
SharePoint 2010 branding project included importing a master page and making a few edits. I
noticed right away that when I imported my master page in 2010 it wasn't in the master page
folder. Heres what was happening:
In SharePoint Designer 2007, both the master pages and the page layouts are stored in the
masterpage folder located in the _catalogs folder. However, in SharePoint Designer 2010 there
are separate files, one for master pages and another for page layouts. If you open SharePoint in a
web browser and click Site Actions, click Site Settings, and then click Master pages and page
layouts in the Galleries section, you'll see that your master page was uploaded successfully.
You'll also notice that the icon next to the file name indicates that it's a master page file. But why
is it not showing up in the master page folder in SharePoint Designer 2010?
If you choose Edit Properties for the master page file, you'll see that the Content Type titled Page
Layout was selected by default when the master page was uploaded. As a result, the master page
that you recently uploaded is in the Page Layout folder, not in the Master Pages folder. To
change this, simply change the content type of your master page to Publishing Master Page as
shown in Figure 1. In SharePoint Designer 2010, refresh the Master Pages folder by pressing f5
and you'll see your imported master page in SharePoint Designer's Master Pages folder.



Tip 2: Pin a gallery. In SharePoint Designer 2007, I was used to developing with the Folder List
always visible on the left side. Fortunately, in 2010 we are able to pin a gallery so that a mini-
gallery is always visible below the navigation pane as shown in Figure 2. To pin a gallery, first
hover over the link that you want to pin, and then click the pin icon when it appears. This gallery
will continue to be displayed even if you browse to another gallery.



Tip 3: Use Ctrl +click to jump to the code of a class. Both SharePoint Designer 2007 and 2010
provide a helpful feature that lets you click an underlined class name while holding down the
Ctrl key. Do this in your master page or page layout and you will go directly to that piece of
code. For example, if you click class="ms-TurnOffAcc" in your master page, the corev4.css file
(where that class is located) will open. Additionally, you'll be taken directly to that piece of code
within that file. Figure 3 shows this feature in action.

Tip 4: Access the Toolbox easily. I've received several questions regarding opening the Toolbox
in SharePoint Designer 2010. After you have opened an editable 2010 file, such as a master page
or a .css file, the View tab will appear on the ribbon. Just click the Task Panes drop-down list
from the ribbon, and then click Toolbox. (See Figure 4.)

Tip 5: Know the difference between Page fields and Content fields. In the Toolbox, you'll find a
list of Page fields and Content fields. Why are these site columns categorized differently? The
Page Fields category contains site columns that are inherited from the parent content type from
which the page layout was created. The Content Fields category contains site columns that are
specific to the content type that the page layout was created from. Figure 5 shows a list of Page
fields and Content fields.

Master Page Tips
These master page branding tips are needed for almost every branding project.
Tip 6: Use the After property to force a .css file to load after another. When you reference a
.css file in your master page, the After property is helpful. The After property is new to
SharePoint 2010 and is used to force a .css file to load one after the other. For example, if you
reference a custom .css file in your master page and the After property reads After="corev4.css",
your custom .css file will load after the out-of-the-box corev4.css file. You can use this After
property more than once to specify that an entire list of .css files should load one after the other.
In the following example, customfile1.css loads after corev4.css:
<SharePoint:CSSRegistration Name="/Style
Library/customfile1.css" After="corev4.css" runat="server"/>
Here is another example showing how customfile2.css loads after customfile1.css:
<SharePoint:CSSRegistration Name="/Style
Library/customfile2.css" After="customfile1.css"
runat="server"/>
Tip 7: Use the $SPUrl token to reference a .css file.If you need to make a reference to your .css
file and specify that it's located at either the root of a site collection or at the root of a subsite site,
you can use a $SPUrl token.
Here's an example of how to reference a .css file that's located at the root of a site collection:
<SharePoint:CSSRegistration name=<% $SPUrl:~sitecollection/Style
Library/customfile.css %>" after="corev4.css" runat="server"/>
And here's an example of how to reference a .css file that's located at the root of a subsite site:
<SharePoint:CSSRegistration name=<% $SPUrl:~site/Style
Library/customfile.css %>" after="corev4.css" runat="server"/>
Tip 8: Apply master pages to publishing sites. To apply master pages to publishing sites in
SharePoint, click Site Actions, click Site Settings, and then click Master Page under Look and
Feel. You'll see two sections (Site Master Page and System Master Page) that include drop-down
lists.
Site Master Page is used by publishing content pages and is defined by the dynamic token
~masterurl/custom.master in the content page directive. To apply Site Master Page using
SharePoint Designer, right-click a master page file, and click Set as Custom Master Page, as
shown in Figure 6.

System Master Page is used by non-publishing sites, publishing site subpages (such as list views,
libraries, and forms), dialog pop-up windows, and application pages. System Master Page is
defined by the dynamic token ~masterurl/default.master in the content page directive. To apply
System Master Page using SharePoint Designer, right-click a master page file, and click Set as
Default Master Page.
Tip 9: Hide content placeholders not used by SharePoint 2010. A handful of content
placeholders are not required for your SharePoint 2010 master page, but they are required for
backward compatibility. If you know that your master page will be used only for SharePoint
2010, you can hide the backward-compatible content placeholders in your master page to reduce
the amount of HTML that is rendered when the page loads. Note that you cannot delete the
unused content placeholders because you'll receive an error message saying that SharePoint is
looking for that particular content placeholder. The proper thing to do is to hide them.
The out-of-the-box v4.master file uses CSS to override these content placeholders. (Search for
the s4-die class, and you'll see several instances of this class.) However, placing these content
placeholders in a non-visible panel instead of hiding them through CSS is a more efficient option
that will help your page to load faster. Figure 7 shows nine non-required content placeholders in
a non-visible panel.

Tip 10: Get to know the master pages. Four out-of-the-box master pages are often used for
branding in SharePoint 2010. The default.master page, also known as v3 master, is equivalent to
the default master page in SharePoint 2007. If you apply this master page to your SharePoint
2010 site, you'll notice that the ribbon is stripped out and the Site Actions menu is located to the
right of the global navigation container. This is the master page that is used when SharePoint
2007 is upgraded to 2010. It can be used only when SharePoint 2010 is in SharePoint 2007 mode
via Visual Upgrade.
The v4.master page is the default team site master page and can be used for both publishing and
non-publishing sites, whereas the nightandday.master page is used only for publishing sites. The
nightandday.master page is similar to the Blueband master page that came with SharePoint 2007.
At first glance, the minimal.master page appears to be a starter master page, but it is not. This
master page is used for sites that have their own navigation control or that need additional space
to display content. For example, the search center and Office Web Applications use the
minimal.master master page.
Tip 11: I mplement a fixed-width design. Most custom SharePoint branding projects require a
fixed-width site design. If this is the case for your project, there is more than one approach to suit
your needs. When you are deciding which option is best for your project, it's important to
understand how the ribbon, although invaluable, can create complexity when creating a fixed-
width site.
SharePoint's ribbon positioning method causes the ribbon to remain positioned at the top of the
page. It also replaces the browser's traditional scrolling method by using JavaScript to analyze
the size of the page and inserts a custom scroll bar underneath the ribbon. Following are several
approaches that you can take to implement a fixed-width design. As you will see, each approach
has its pros and cons. The following tips are not targeted to anonymous access enabled sites.
The quickest and most straightforward approach is to simply modify a few default CSS classes to
make both the ribbon's contents and the site design a fixed width. This method makes the site a
fixed width, and the width of the ribbon's contents matches the width of the site design. Because
only the ribbon's contents are a fixed width, the ribbon container remains the full width of the
browser. However, this approach may conflict with your design. Add the CSS code in Figure 8
below to your master page or style sheet:
/*This creates a fixed-width site design. Applying the fixed-
width to #s4-bodyContainer keeps the scroll bar to the far right
side of the site.*/

#s4-bodyContainer {

width: 960px !important;

margin:auto;

}


/* This makes the contents of the ribbon a fixed-width*/

.ms-cui-ribbonTopBars, ms-cui-tabBody {

width:960px;

margin:auto;

}


/*This removes a white line that's underneath the ribbon and
looks out of place when the ribbon's contents are a fixed-
width*/

.ms-cui-ribbonTopBars div {

border-bottom:1px solid transparent;

}
Figure 9 illustrates this approach.




The second option is to fix the width of the body area and the entire ribbon. This approach works
well if your design looks best when the entire ribbon is a fixed width. However, there will be
unused space that the background of the ribbon used to fill at the top of the scroll bar. Add the
CSS code in Figure 10 below to your master page or style sheet:
/*Scroll bar is added if overflow is clipped.*/
body.v4master {
overflow:auto;
}

/*This creates a fixed-width site design. Applying the fixed-
width to #s4-bodyContainer keeps the scroll bar to the far right
side of the site.*/
#s4-bodyContainer {
width: 960px !important;
margin:auto;
}
/*This makes the entire ribbon a fixed width.*/
#s4-ribbonrow {
width:960px;
margin:auto;
}
The results will appear as shown in Figure 11.



You can remove the extra white space where the background of the ribbon used to be by
completely reverting back to the browser's traditional scroll bar. To do this, the ribbon
positioning method needs to be turned off or removed. The ribbon positioning method can be
removed when the ID s4-workspace is deleted from the master page. Please note that there are
consequences to removing this ID from the master page. One known consequence is that the
Gantt view of a project list no longer appears. To use this approach, search for id="s4-
workspace" and remove it from the <div> container in your master page. Figure 12 shows
SharePoint using traditional scroll bars:



The last option is to add inline styles to your master page to set a fixed width to the ribbon and
the main workspace. Then, turn off the ribbon positioning method to revert to the browser's
standard scrolling system. This topic was covered in part two of the article SharePoint Branding
101: Customizing Your SharePoint Site.
To center the ribbon and make it a fixed width, perform a search for id="s4-ribbonrow". Add a
width style of 960px to the <div> tag, and set the margins to auto, as follows:
<div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle"
style="width:960px; margin:auto">
To center the main workspace and make it a fixed width, perform a search for id="s4-
workspace". Add the class s4-nosetwidth to the <div> tag, add a width style of 960px, and set the
margins to auto, as follows:
<div id="s4-workspace" class="s4-nosetwidth" style="width:960px;
margin:auto">
Note that the class s4-nosetwidth tells SharePoint not to override our fixed width with inline
styling when the page loads in the browser. To revert to the browser's standard scrolling method,
search for id="s4-workspace" and remove it from the <div> container in your master page.
Tip 12: Manage the code that provides error messages to legacy browsers.Toward the bottom
of an out-of-the-box master page, a line of code has been inserted to provide an error message for
users who are viewing SharePoint 2010 in an unsupported browser. You can insert this line of
code in your own custom master pages as well. If you don't want this warning to be presented to
all users, simply remove the following line of code from the master page:
<SharePoint:WarnOnUnsupportedBrowsers runat="server" />
Tip 13: Add a traditional breadcrumb. SharePoint 2010 doesn't come with the same traditional
breadcrumb that SharePoint 2007 offered. Instead, it uses a pop-out hierarchical global
breadcrumb found on the ribbon and a combination of site title and current page title (or list title)
in the header area that can also serve as a type of breadcrumb. However, a lot of clients definitely
miss (and will ask for) a traditional breadcrumb. Thank goodness its simple enough to add.
To add the traditional SharePoint 2007 breadcrumb to your new SharePoint 2010 master page,
just add the following line of code:
<asp:SiteMapPath runate="server" />
You might want to add some styling around it as well so that it matches your brand.
Tip 14: Get familiar with the CSS class s4-notdlg. As you're probably already aware, there are
many new CSS classes that are unique to SharePoint 2010. In addition to the s4-nosetwidth class,
which was already discussed in the master page section of this article, here is another CSS tip
that is often needed when branding in SharePoint 2010.
I mentioned in Tip 8 that the master page identified as System Master Page will be applied to
dialog pop-up windows. You'll notice several instances of the s4-notdlg class within out-of-the-
box SharePoint 2010 master pages. This class tells SharePoint not to apply the particular element
that the class wraps around to the dialog box. For example, if you create a custom master page
with a custom header and apply the s4-notdlg class to that element, the header will not appear in
the dialog pop-up window. If you do not apply the class s4-notdlg, the header will appear in the
dialog pop-up window.
Tip 15: Turn on full error messages. This tip isn't actually new to SharePoint 2010, but it's still
definitely helpful. By default, SharePoint turns custom errors on so that users see a more friendly
error message. However, the custom error messages do not provide any help for designers trying
to troubleshoot an issue. Turning off custom error messaging is simple. Perform the following
steps on the development web server to turn off custom errors:
1. Navigate to the following site directory:
<Local drive>:\inetpub\wwwroot\wss\VirtualDirectories\[sub
directory with port number of your SharePoint site]
2. Locate the web.config file, and make a copy of it as a backup.
3. In Notepad, open the web.config file.
4. Search for "CallStack." You will find the following:
<SafeMode MaxControls="200" CallStack="false"
DirectFileDependencies="10" TotalFileDependencies="50"
AllowPageLevelTrace="false">
5. Change the value of the CallStack and AllowPageLevelTrace attributes to true.
6. Search for "CustomErrors," and then change the CustomErrors mode to Off.
7. Save and close the file.
The cache for the website for which you changed the web.config file is invalidated and reloaded.
Now the site will display the ASP.NET error page, which displays the full error message and the
exception stack trace.






SharePoint 2010 Interview Questions IT Pro / Architect
Basic Intro SharePoint Architecture Questions
1) What are Web Applications in SharePoint?
An IIS Web site created and used by SharePoint 2010. Saying an IIS virtual server is also an
acceptable answer.
2) What is an application pool?
A group of one or more URLs that are served by a particular worker process or set of worker
processes.
3) Why are application pools important?
They provide a way for multiple sites to run on the same server but still have their own worker
processes and identity.
4) What are zones?
Different logical paths (URLs meaning) of gaining access to the same SharePoint Web
application.
5) What are Web Application Policies?
Enables security policy for users at the Web application level, rather than at the site collection or
site level. Importantly, they override all other security settings.
6) What is a site collection?
A site collection contains a top-level website and can contain one or more sub-sites web sites
that have the same owner and share administration settings.
7) What are content databases?
A content database can hold all the content for one or more site collections.
8) What is a site?
A site in SharePoint contains Web pages and related assets such as lists, all hosted within a site
collection.
9) What are My Sites?
Specialized SharePoint sites personalized and targeted for each user.
10) What is the difference between Classic mode authentication and Claims-based
authentication?
As the name implies, classic authentication supports NT authentication types like Kerberos,
NTLM, Basic, Digest, and anonymous. Claims based authentication uses claims identities
against a against a trusted identity provider.
11) When would you use claims, and when would you use classic?
Classic is more commonly seen in upgraded 2007 environments whereas claims are the
recommended path for new deployments.
12) Describe the potential components for both a single server, and multiple servers,
potentially several tiered farms:
A single-server SharePoint Server 2010 environment leverages a built-in SQL Server 2008
Express database. The problems with this environment is scalability, not being able to install the
with built-in database on a domain controller, the database cannot be larger than 4 GB, and you
cannot use User Profile Synchronization in a single server with built-in database installation.
An example of a multiple tier farm would be a three-tier topology, considered one of the more
efficient physical and logical layouts to supports scaling out or scaling up and provides better
distribution of services across the member servers of the farm. This is considered a good
architecture since one can add Web servers to the Web tier, add app servers to the application
tier, and add database servers to the database tier.
SharePoint Backup and Restore Questions
13) What are some of the tools that can be used when backing up a SharePoint 2010
environment?
SharePoint farm backup and recovery
SQL Server
System Center Data Protection Manager
14) What Microsoft tool can be used for incremental backups?
System Center Data Protection Manager
Managed Metadata Questions
15) What is Managed Metadata?
Managed metadata is a hierarchical collection of centrally managed terms that you can define,
and then use as attributes for items.
16) What are Terms and Term Sets?
A term is a word or a phrase that can be associated with an item. A term set is a collection of
related terms.
17) How do Terms And Term Sets relate to Managed Metadata?
Managed metadata is a way of referring to the fact that terms and term sets can be created and
managed independently from the columns themselves.
18) Are there different types of Term Sets?
There are Local Term Sets and Global Term Sets, one created within the context of a site
collection and the other created outside the context of a site collection, respectively.
19) How are terms created and used?
There are several ways; however the most common is to use the Term Store Management Tool.
20) How is Managed Metadata, and the related Term technology used?
Through the UI, the most common use is through the managed metadata list column which
allows you to specify the term set to use. It also related to searching and enhancing the user
search experience.
Sandbox Solutions Questions
21) What is a sandboxed solution?
Components that are deployed to run within the sandboxed process rather than running in the
production Internet Information Services (IIS) worker process.
22) What are some examples of things that might run within the SharePoint sandbox?
Any of the following are acceptable answers:
Web Parts
Event receivers
Feature receivers
Custom Microsoft SharePoint Designer workflow activities
Microsoft InfoPath business logic
others.
23) Why are sandboxed solutions used?
Primarily because they promote high layers of isolation. By default they run within a rights-
restricted, isolated process based around Code Access Security (CAS). Isolation is possible to
increase with activities like running the sandboxing service on only specific SharePoint 2010
servers.
SharePoint Search Questions
24) What is a content source in relation to SharePoint search? Whats the minimum
amount of content sources?
A content source is a set of options that you can use to specify what type of content is crawled,
what URLs to crawl, and how deep and when to crawl. You must create at least one content
source before a crawl can occur.
25) What is a search scope?
A search scope defines a subset of information in the search index. Users can select a search
scope when performing a search.
26) What is a federated location with SharePoint search?
Federated locations provide information that exists outside of your internal network to your end-
users.
27) How does managed metadata affect search?
Enhances the end-user search experience by mapping crawled properties to managed properties.
Managed properties show up in search results and help users perform more successful queries.
28) What is query logging in SharePoint 2010?
Collects information about user search queries and search results that users select on their
computers to improve the relevancy of search results and to improve query suggestions.
29) What authentication type does the SharePoint crawler use?
The crawl component requires access to content using NTLM authentication.
Services Architecture Questions
30) Please describe what a Service Application is in SharePoint 2010.
Service applications in SharePoint 2010 are a set of services that can possibly be shared across
Web applications. Some of these services may or may not be shared across the SharePoint 2010
farm. The reason these applications are shared is the overall reduction of resources required
to supply the functionality these services cultivate.
31) Please provide an example of one of these service applications.
Any of the below are acceptable answers:
Access Services
Business Data Connectivity service
Excel Services Application
Managed Metadata service
PerformancePoint Service Application
Search service
Secure Store Service
State service
Usage and Health Data Collection service
User Profile service
Visio Graphics Service
Web Analytics service
Word Automation Services
Microsoft SharePoint Foundation Subscription Settings Service
32) What are Service Application Groups used for?
Just provides a logical grouping of services that are scoped to a particular Web Application.
33) How are Service Applications deployed in terms of IIS (Internet Information Services)?
They are provisioned as a single Internet Information Services (IIS) Web site.
34) Explain how connections are managed with Service Applications.
A virtual entity is used that is referred to as a proxy, due to label in PowerShell.
35) What are some common examples of SharePoint 2010 services architectures, and what
are the advantages of each design?
The three most popular designs are single farms with either a single service application group or
multiple service application groups, or Enterprise services farms.
Single farms with a single service application group are generally the most common, and have
the advantages of easy deployment, simple service application allocation, effective resource
utilization and cohesive management.
Single farms with multiple service application groups is less common, and have the advantage of
potential individual management of service applications as well as allowing data isolation, and
while being more complex to deploy and maintain allows targeting of sites to particular service
applications.
Enterprise Service Farms is pretty uncommon as it is a complete farm dedicated to Service
Applications but promotes autonomous management and high levels of data isolation.
36) Are there any other type of relevant service architectures?
Depending on the environment requirements, a specialized farm can also be used in order to
deploy specific services tailored to the organizational requirements which can aid in scaling out
and conservation of resources.
37) What is the User Profile service?
Allows configuring and managing User profile properties, Audiences, Profile synchronization
settings, organization browsing and management settings, and My Site settings.
38) What are User Profiles?
Aggregates properties from diverse identity content sources together to create unified and
consistent profiles across an organization, used throughout the SharePoint environment.
39) What is Excel Services?
Allows sharing, securing, managing, and using Excel 2010 workbooks in a SharePoint Server
Web site or document library. Excel Services consists of the Excel Calculation Services (ECS),
Microsoft Excel Web Access (EWA), and Excel Web Services (EWS) components.
40) What is PerformancePoint Services?
Allows users to monitor and analyze a business by building dashboards, scorecards, and key
performance indicators (KPIs).
41) What is Visio Services?
Allows users to share and view Microsoft Visio Web drawings. The service also enables data-
connected Microsoft Visio 2010 Web drawings to be refreshed and updated from various data
sources.
42) What is Access Services?
Allows users to edit, update, and create linked Microsoft Access 2010 databases that can be
viewed and manipulated by using an internet browser, the Access client, or a linked HTML page.
43) What is the Secure Store Service (SSS)?
A secure database for storing credentials that are associated with application IDs
44) What is Content Deployment?
Content deployment enables you to copy content from a source site collection to a destination
site collection.
Backup / DR Questions
45) Describe how redundancy can be built into a SharePoint environment. Please be
specific in regards to any auxiliary components.
Multiple front-end web servers (WFEs) can be deployed and correlated through Windows NLB
or anything approach. Application servers can be deployed into the farm for a variety of
purposes, depending on organizational requirements. Databases can be clustered or mirrored,
again depending on requirements and environment.
46) From a basic standpoint, what is the difference between SQL clustering and mirroring?
Clustering provides a failover scenario whereby one or more nodes can be swapped as active
depending on whether a node goes down. In mirroring, transactions are sent directly from a
principal database and server to a mirror database to establish essentially a replica of the
database.
Governance Questions
47) What Is Governance in terms of SharePoint 2010?
Governance is the set of policies, roles, responsibilities, and processes that guide, direct, and
control how an organizations business divisions and IT teams cooperate to achieve business
goals.
48) What are some useful, OOB features of SharePoint that aid with governance of an
environment?
Any of the below are acceptable answers. There are some others but these are the major ones that
I generally look for from a candidate:
Site templates consistent branding, site structure, and layout can be enforce a set of
customizations that are applied to a site definition.
Quotas limits to the amount of storage a site collection can use.
Locks prevent users from either adding content to a site collection or using the site collection.
Web application permissions and policies comprehensive security settings that apply to all
users and groups for all site collections within a Web application.
Self-service site creation enables users to create their own site collections, thus must be
incorporated into a governance scheme.
Monitoring Questions
49) Describe the monitoring features that are baked into SharePoint 2010.
Diagnostic logging captures data about the state of the system, whereas health and usage data
collection uses specific timer jobs to perform monitoring tasks, collecting information about:
Performance Counter Fata
Event Log Data
Timer Service Data
Metrics For Site Collections and Sites
Search Usage Data
General Workflow Questions
50) What is a declarative workflow? Can non-authenticated users participate in
workflows?
Workflows created by using Microsoft SharePoint Designer 2010, the default setting enables
deployment of declarative workflows. Yes, however you do not give non-authorized users access
to the site. The e-mail message and attachments sent from notifications might contain sensitive
information

What Is a View?
Using views is a useful way for a list manager to create different ways to show the information in
a list or library. Different views may show different columns and have different sorting and
filtering, grouping, and styles.
In SharePoint, views can be either public or private:
PublicThe list's or library's managers create public views, and these views are available to
anyone to use.
PrivateUsers create private views. Only the user who created a private view can use that view.
You may, for example, create a private view and customize it to show the information that you
usually need to find the items or files that you usually work with.
Modify the browser definition file (compat.browser)
The browser definition file contains a list of the mobile browsers and devices that can access
mobile views in SharePoint Foundation. When a user browses a SharePoint site from a mobile
device, the mobile browser submits to the site an HTTP GET request that includes a user agent
string. If the mobile browser and device model in the user agent string are listed in the browser
definition file and the isMobileDevice setting for the mobile browser is set to true, SharePoint
Foundation redirects the mobile browser to the mobile view of the site. Otherwise, a standard
view of the site is shown in the mobile browser. You can modify the file to change the redirect
behavior of a mobile browser.
The browser definition file lists the mobile browsers and devices that are supported by
SharePoint Foundation. The file can be updated when product updates to SharePoint Foundation
are released. You can also modify the file to add a mobile browser or device to the list.
Note
There is a compat.browser file for each Internet Information Services (IIS) Web site.
To change the redirect behavior of a mobile browser
1. Start IIS Manager by typing INETMGR at a command prompt.
2. Right-click the IIS Web site where the SharePoint Web application is installed, and then
click Explore.
3. In Windows Explorer, double-click the App_Browsers folder.
4. Open the compat.browser file in a text editor.
5. Find the <browser> node that corresponds to the mobile browser or device that you want
to modify.
6. Find the <capability name="isMobileDevice" value="true" /> element.
7. Set the value attribute to false to display a standard view of the site in the mobile
browser.
8. Save your changes to the compat.browser file.
9. Restart IIS by entering the following command at the command prompt: iisreset
/noforce.
To add a mobile browser or device, you create a <browser> node that identifies the mobile
browser or device and defines its capabilities. For more information about what can be entered in
the <browser> node, see Browser Definition File Schema (browsers Element)
(http://go.microsoft.com/fwlink/p/?LinkID=146162).
To add a mobile browser and device model
1. Start IIS Manager by typing INETMGR at a command prompt.
2. Right-click the IIS Web site where the SharePoint Web application is installed, and then
click Explore.
3. In Windows Explorer, double-click the App_Browsers folder.
4. Open the compat.browser file in a text editor.
5. Find the <browsers> node.
6. Add a new <browser> node to the end of the list of browsers.
7. Save your changes to the compat.browser file.
8. Restart IIS by entering the following command at the command prompt: iisreset
/noforce.

You might also like