Tải bản đầy đủ (.pdf) (276 trang)

Microsoft SharePoint 2010 development cookbook ppt

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.55 MB, 276 trang )

Microsoft SharePoint
2010 Development
Cookbook
Over 45 recipes to take you from beginner to professional
in SharePoint Development
Ed Musters
BIRMINGHAM - MUMBAI
Do wn lo ad f ro m Wo w! eBook <www.wowebook.com>
Microsoft SharePoint 2010 Development
Cookbook
Copyright © 2011 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly
or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2011
Production Reference: 2161211
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84968-150-6
www.packtpub.com


Cover Image by Sandeep Babu ()
Credits
Author
Ed Musters
Reviewers
Thomas Ledan
Sothilingam Jeyashanker
Acquisition Editor
Dilip Venkatesh
Development Editor
Susmita Panda
Technical Editors
Sakina Kaydawala
Mehreen Shaikh
Ankita Shashi
Copy Editor
Leonard D'Silva
Project Coordinator
Michelle Quadros
Proofreader
Stephen Silk
Indexers
Hemangini Bari
Tejal Daruwale
Production Coordinator
Prachali Bhiwandkar
Cover Work
Prachali Bhiwandkar
About the Author
Ed Musters is a SharePoint MVP and a SharePoint Architect for Infusion. He has been an

instructor for the exclusive Critical Path SharePoint courses for many years. Ed is an author
of two books on SharePoint 2010 development. He has been a featured speaker at many
international conferences, SharePoint Saturdays, and user groups. Ed enjoys sharing his
real-world expertise with the readers!
He has earlier worked on the Expert SharePoint 2010 Practices book, (ISBN: 1430238704).
I would like to thank Ted and Andrew of Critical Path Training for starting
me on my SharePoint journey, the folks at Telerik for their fantastic support
for my community work, and nally, my loving wife Gala for her unwavering
support for this project.
About the Reviewers
Thomas Ledan has worked for 10 years in application and website development with
Microsoft technologies and more particularly in SharePoint.
Initially, he was a web developer, and then became a technical leader for SharePoint from
2006 to 2010 and managed a development team of four.
He is now a senior consultant at SoftFluent, an innovative company founded in 2005 by
Microsoft veterans.
I would like to thank Ed for providing this nice cookbook and I hope it
will be a great help for all the readers. Above all, I would like to thank my
wife Zuzana for supporting me and taking care of our children while I was
concentrating on Ed's work.
Sothilingam Jeyashanker is a Senior SharePoint Developer/Administrator at DHI Water
& Environment (S) Pte. Ltd. He has many years of hands-on experience in SharePoint projects
in various industries, both in the private and government sectors. He began his career
with 'dBase III +' and 'Pascal' and he is currently engaged full time with 'SharePoint 2010.'
Previously, he has worked for several Microsoft gold partner companies and obtained his
M.E. degree in Computer Science and Engineering from Anna University, in Chennai, India.
I take this opportunity to thank three people—rst, my friend Loga, who is
the reason for me entering the world of software; second, the Government
of Singapore for the opportunities that they provided me to grow
professionally in this high- tech nation; and third, DHI Water & Environment

(S) Pte. Ltd., for giving me the opportunity to work with cutting edge
technologies and giving me the chance to explore new possibilities.
www.PacktPub.com
Support les, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support les and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub les
available? You can upgrade to the eBook version at www.PacktPub.com and as a print book
customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@
packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library.
Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
f Fully searchable across every book published by Packt
f Copy and paste, print and bookmark content
f On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib
today and view nine entirely free books. Simply use your login credentials for immediate access.
Instant Updates on New Packt Books
Get notied! Find out when new books are published by following @PacktEnterprise on Twitter,
or the Packt Enterprise Facebook page.
Table of Contents
Preface 1
Chapter 1: Setting Up a Development Environment 7
Introduction 7
Selecting your virtual environment 9
Installing and conguring Windows Server 2008 R2 10

Installing and conguring SQL Server 2008 R2 15
Installing and conguring SharePoint Server 2010 20
Installing Microsoft Ofce 2010 Professional 27
Installing Visio Premium 2010 29
Installing SharePoint Designer 2010 30
Installing Visual Studio 2010 30
Installing recommended developer tools 32
Setting up your rst web application 33
Chapter 2: SharePoint Development with Visual Studio 43
Introduction 43
Exploring Content Types and Site Columns 44
Features and Solutions 47
Creating new Site Columns 49
Packaging SharePoint Solutions 57
Creating new Content Types 61
Creating document libraries with Content Types 65
Feature Receivers 68
List Event Receivers 70
Feature Staplers 74
Chapter 3: Web Part Development 77
Introduction 77
Exploring Web Parts in SharePoint 2010 78
Creating and deploying Web Parts with Visual Studio 2010 81
ii
Table of Contents
Creating Visual Web Parts 87
Creating custom Web Part properties 91
Creating Editor Parts for custom Web Part properties 97
Creating Connected Web Parts 104
Chapter 4: Development with SharePoint Designer 2010 117

Introduction 117
Exploring SharePoint Designer 2010 118
Working with the XSLT List View Web Part 122
Creating List Forms with SharePoint Designer 132
Creating List Forms with InfoPath 135
Enabling Inline Edit mode 142
Chapter 5: Using the ClientOM and REST 145
Introduction 145
Retrieving data using LINQ to SharePoint 146
Retrieving SharePoint data using the list data service 151
Working with the .NET Client Object Model 155
Working with the Silverlight Client Object Model 161
Chapter 6: External Data 171
Introduction 171
Getting your data ready for the chapter 172
Using the Data Form Web Part with SQL Server 181
Using the Data Form Web Part with WCF data 188
External Content Types and Lists 194
Using Business Data Web Parts 203
Chapter 7: SharePoint Workows 209
Introduction 209
Using out-of-the-box workows 210
Copying and extending out-of-the-box workows
with SharePoint Designer 2010 217
Using Visio 2010 to create workows 224
Using SharePoint Designer 2010 to implement Visio 2010 workows 226
Developing workows in Visual Studio 2010 231
Chapter 8: Web Content Management 239
Introduction 239
Creating Publishing Pages 240

Modifying navigation settings 247
Creating and Using Page Layouts 248
SharePoint 2010 Branding 254
Index 259
Preface
There is a heavy demand in the marketplace for SharePoint developers that you could
take advantage of—if only you had the opportunity to acquire the relevant skills! However,
SharePoint 2010 is a big, old, product with a steep learning curve—so where
do you begin?
This book has been designed to take the experienced ASP.NET developer from beginner
to professional SharePoint developer in the shortest amount of time. You will be productive
on your very rst SharePoint development assignment with the knowledge and skills that
you learn here. You will have distilled the essence of the author's many years of training,
and leading development teams in SharePoint.
This book uncovers the most common "pattern" of SharePoint development tasks
encountered in the real world and puts the topics into a logical order with detailed
step-by-step recipes for you to follow.
The practical examples that are given build-up and ow throughout the chapters. By the
end of this book, you will be able to apply the concepts to the challenges ahead of you!
What this book covers
Chapter 1, Setting up a Development Environment: In this chapter, you will build a fully
functional SharePoint 2010 server and an integrated SharePoint development environment
in a virtualized setting.
Chapter 2, SharePoint Development with Visual Studio: This chapter will introduce SharePoint
2010 development with Visual Studio—packaging with features and deploying with solutions.
It will introduce the denition of "schema" SharePoint style—site columns, content types, and
list denitions—as applied to a document library. The SharePoint equivalent of a database
"trigger" will be introduced—the list event receiver.
Chapter 3, Web Part Development: This chapter will cover web control development with
SharePoint, including user controls and Web Parts. More advanced web part development

will be covered including Web Part properties, Editor Parts, and connected Web Parts.
Do wn lo ad f ro m Wo w! eBook <www.wowebook.com>
Preface
2
Chapter 4, Development with SharePoint Designer 2010: This chapter introduces SharePoint
Designer 2010 as an important tool for the developer. You will apply this tool in this chapter
to work with lists. You will learn about the very important XSLT List View Web Part, and about
creating list forms with both ASPX and InfoPath.
Chapter 5, Using the Client OM and REST: This chapter will introduce the retrieval of
SharePoint data via Language Integrated Query (LINQ) and via the List Data Service (REST).
The resulting data query will then be demonstrated in a Web Part, and via the Client Object
Model in both a Windows and Silverlight application.
Chapter 6, External Data: This chapter shows you how to connect to data that is "outside"
of SharePoint, either in databases or via web services. Surprisingly powerful out-of-the-box
capabilities will allow you to do most of this with "no code"—with Business Data Web Parts,
with SharePoint Designer 2010, and with External Content Types and Lists. You will also learn
to wrap existing data in SQL Server with a custom developed WCF Data Service that is then
consumed in SharePoint 2010.
Chapter 7, SharePoint Workows: This chapter covers using an out-of-the-box approval
workow and then extending that with SharePoint Designer 2010. Along the way, we are
introduced to the workow form types—Association, Initiation, and Task Edit. Then we learn
the tools for developing new workows—Visio 2010, SharePoint Designer 2010, and Visual
Studio 2010.
Chapter 8, Web Content Management: This chapter provides a "non-developer" overview of
the "other important side" of SharePoint. It also covers the concepts of publishing pages, page
layouts, and master pages that are used within the Web Content Management capabilities of
SharePoint to deliver public-facing websites.
What you need for this book
In order to run the examples in the book, the following software will be required:
f Microsoft Server software

 Windows Server 2008 R2
 SQL Server 2008 R2 Enterprise
 SharePoint Server 2010 Enterprise
f Microsoft Ofce Software:
 Microsoft Ofce 2010 Professional
 Visio Premium 2010
 SharePoint Designer 2010
f Development Tools:
 Visual Studio 2010 Professional or Ultimate
 Imtech Get SPMetal Denition Extension3
Preface
3
Note that the links given will lead you to downloadable trial software that will, by denition,
have an expiry date. Feel free to replace this with your own licensed software, such as an
MSDN subscription.
# Software Name URL
1 Windows Server
2008 R2
/>details.aspx?displaylang=en&id=11093
2 SQL Server 2008
R2 Enterprise
/>ff459612
3 SharePoint 2010
Enterprise
/>evalcenter/ee388573
4 Microsoft Ofce
2010 Professional
/>evalcenter/ee390818
5 Visio Premium
2010

/>evalcenter/ee390821
6 SharePoint
Designer 2010
/>details.aspx?id=16573
7 Visual Studio 2010
Ultimate Trial
/>details.aspx?id=12187
8 SP Metal Extension
rosoft.
com/c523e7ba-ba9d-45c4-98ea-b02b19f81640/
Who this book is for
This book is written for the ASP.NET developer who wants to become a professional
SharePoint 2010 developer as quickly as possible, by learning the most important
practical aspects of development that will be used in the real world.
Conventions
In this book, you will nd a number of styles of text that distinguish between different kinds of
information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "With CreateChildControls, you can literally
create a control such as a Label or TextBox and add it to the controls collection."
Preface
4
A block of code is set as follows:
protected override void CreateChildControls()
{
Label myLabel1 = new Label();
myLabel1.Text = "SharePoint 2010 Cookbook Chapter 3 - This Web
Part uses CreateChildControls";
this.Controls.Add (myLabel1);
}
When we wish to draw your attention to a particular part of a code block, the relevant lines

or items are set in bold:
<data>
<properties>
<property name="Title" type="string">Web Part Using Render
Contents</property>
<property name="Description" type="string">This Web Part demos
overriding Render Contents.</property>
</properties>
</data>
Any command-line input or output is written as follows:
# cp /usr/src/asterisk-addons/configs/cdr_mysql.conf.sample
/etc/asterisk/cdr_mysql.conf
New terms and important words are shown in bold. Words that you see on the screen, in
menus, or dialog boxes for example, appear in the text like this: "clicking the Next button
moves you to the next screen".
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this
book—what you liked or may have disliked. Reader feedback is important for us to develop
titles that you really get the most out of.
Preface
5
To send us general feedback, simply send an e-mail to , and
mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in
the SUGGEST A TITLE form on
www.packtpub.com or e-mail
If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you
to get the most from your purchase.
Downloading the example code
You can download the example code les for all Packt books you have purchased from your
account at . If you purchased this book elsewhere, you can visit
and register to have the les e-mailed directly to you.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen.
If you nd a mistake in one of our books—maybe a mistake in the text or the code—we would be
grateful if you would report this to us. By doing so, you can save other readers from frustration
and help us improve subsequent versions of this book. If you nd any errata, please report
them by visiting selecting your book, clicking on
the errata submission form link, and entering the details of your errata. Once your errata are
veried, your submission will be accepted and the errata will be uploaded on our website, or
added to any list of existing errata, under the Errata section of that title. Any existing errata can
be viewed by selecting your title from />Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt,
we take the protection of our copyright and licenses very seriously. If you come across any
illegal copies of our works, in any form, on the Internet, please provide us with the location
address or website name immediately so that we can pursue a remedy.
Please contact us at
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at if you are having a problem with any
aspect of the book, and we will do our best to address it.

1
Setting Up a

Development
Environment
In this chapter, we will cover:
f Selecting your virtual environment
f Installing and conguring Windows Server 2008 R2
f Installing and conguring SQL Server 2008 R2
f Installing and conguring SharePoint Server 2010
f Installing Microsoft Ofce 2010 Professional
f Installing Visio Premium 2010
f Installing SharePoint Designer 2010
f Installing recommended developer tools
f Setting up your rst web application
Introduction
Before one can consider himself/herself a true SharePoint 2010 developer, you must be
capable of creating your very own development environment. Rather like the Jedi requirement
of crafting your very rst light saber; ok, it's not really that mystical, or that difcult to do, but I
assure you that you will nd the experience highly gratifying.
Setting Up a Development Environment
8
This chapter will take you through all the recipes that you require to build your very own
development environment. This will be done in a step-by-step manner, via the suggested best
practice of using a Windows Server 2008 R2 server as the base operating system running on
a virtual machine.
This chapter will result in a standalone self-contained
environment that will serve you very well as you learn
SharePoint development, while teaching you the key
ingredients that are required for you to be successful.
This chapter is not meant to be followed as a guide for building any type of production
server - for example, it does not follow best practices for database naming or service
accounts; having SQL and/or Active Directory on the same box; PowerShell automation,

and so on. It may not be sufcient as a development standard in your organization, so
please consult with your IT department before doing real SharePoint development for
your clients.
What if you have the Windows 7 64-bit version? Can you install and run SharePoint Server
2010 and all other required software and tools? Absolutely you can! Please use your favorite
search engine to seek out the instructions to do so. However, I don't recommend it in practice,
unless you have no other choice. SharePoint is a server-based piece of software, and installing
this on your desktop will inict a heavy price on performance due to the many services (such
as Search) that SharePoint will want to run frequently! There are scripts out there that help
shut down and start up these SharePoint services to help you out. However, I personally like
the convenience of isolating SharePoint 2010 and related development activities to a virtual
machine. You can completely shut this down and put it away for when you need it—by literally
putting it on an external drive. Also, I nd myself developing solutions for many different clients
and projects, and in fact, I have set up a virtual machine for each project, so that, in future, I
can pick up the project for that client from exactly where I left it, by simply ring up the
corresponding virtual environment.
We will be covering selection of a virtual environment in the next section. However, I thought I
would mention that if you have a Windows Server 2008 R2 operating system on hand capable
of running Hyper V, then you have the option of bypassing a full build, and downloading the
Information Worker virtual machine, fully congured with SharePoint 2010, Visual Studio, and
even FAST Search. Use your favorite search engine to nd information worker vm download.
Follow the instructions to download, set up, and activate this virtual machine on a trial basis
(180 day maximum life span).
Chapter 1
9
Presuming you are still reading, you have decided that building your own virtual environment
is the way to go. So let's get to it! I urge you to be patient during this task — this chapter will
take a couple of days for you to complete, as you download many GBs of software and wait
patiently through sometimes long installation processes.
For the software that you will require throughout this chapter, you have two main choices:

1. Preferred: If you or the company that you work for has, access to a Microsoft
Developer Network (MSDN) subscription, then you can download the required
software that provides you with the corresponding activation keys. The main
advantage of this approach is that your virtual environment will be permanent
and licensed, thus you don't have to worry about the software expiring.
2. Alternative: Every single software product mentioned in this chapter is available
for download on a trial basis from the Microsoft site. The main disadvantage of this
approach is that each and every piece of software has a different trial use period.
Many have the ability to extend the trial period, but eventually the environment will
be rendered effectively inoperable and you will have to build the environment again
from scratch. Also, note that the environment is not a properly licensed version, and
is therefore only for trial, exploration, and evaluation uses.
Selecting your virtual environment
Prisoners serving life sentences (in Canada) have what is known as a faint hope clause where
you have a glimmer of a chance of getting parole after 15 years. However, those waiting for
Microsoft to provide us a version of Virtual PC that can run Virtual Hard Drives (VHDs) hosting
64-bit operating systems (such as Windows Server 2008 R2), have no such hope of ever
seeing that piece of software. But miracles do happen, and I hope that the release of a 64-bit
capable Virtual PC renders this section of the chapter obsolete. If this has in fact happened,
go with it and proceed to the following section.
Getting ready
Head into your computer's BIOS settings and enable the virtualization setting. The exact
setting you are looking for varies widely, so please consult with your manufacturer's
documentation. This setting seems universally defaulted to off, so I am very sure you will
need to perform this action.
Setting Up a Development Environment
10
How to do it
Since you are still reading, however, it is safe to say that a miracle has not yet happened.
Your rst task is to select a suitable virtualization technology that can support a 64-bit guest

operating system. The recipe here is to consider the choices in this order, with the outcome of
your virtual environment being selected:
1. Microsoft Virtualization: Hyper-V certainly has the ability to create and run Virtual Hard
Disks (VHDs) with 64-bit operating systems. It's free—that is, you can install the Hyper-V
role, but it requires the base operating system to be Windows Server 2008 R2. It can
be brutal to get it running properly on something like a laptop (for example, because
of driver issues). It won't be a good idea to get Windows 2008 Server running on a
laptop, primarily because of driver issues. I recommend that if your laptop is running
Windows 7, look at creating a dual boot, and a boot to VHD where this other boot option
/ partition is Windows Server 2008 R2. The main disadvantage is coming up with an
(preferably licensed) installation of Windows Server 2008 R2 as the main computer
operating system (or as a dual boot option). Or perhaps your company runs Hyper-V on
their server farm and would be willing to host your development environment for you?
Either way, if you have managed to get access to a Hyper-V server, you are good to go!
2. VMware Workstation: Go to and download my absolute
favorite virtualization technology—VMware Workstation—fully featured, powerful, and
can run on Windows 7. I have used it for years and love it. You must of course pay for
a license, but please believe me, it is a worthwhile investment. You can sign up for
a 30 day trial to explore the benets. Note that you only need one copy of VMware
Workstation to create a virtual machine. Once you have created it, you can run it
anywhere using the freely available VMware Player.
3. Oracle Virtual Box: Go to and download this
free software that will run on Windows 7 and create and host 64-bit guest operating
systems. The reason that this is at the bottom of the list is that I personally do not
have experience using this software. However, I have colleagues who have used it
and have had no problems with it. Give this a try and see if it works as equally well
as a paid version of VMware.
With your selected virtualization technology in hand, head to the next section to install and
congure Windows Server 2008 R2, which is the base operating system required for an
installation of SharePoint Server 2010.

Installing and conguring Windows Server
2008 R2
SharePoint 2010 requires the Windows Server 2008 R2 operating system in order to run. In
this recipe, we will congure the components of Windows Server 2008 necessary in order to
get ready to install SQL Server 2008 and SharePoint 2010.
Chapter 1
11
Getting ready
Download Windows Server 2008 R2 from your MSDN subscription, or type in windows server
2008 R2 trial download into your favorite search engine to download the 180-day trial from
the Microsoft site.
This book does not cover actually installing the base operating system. The specic
instructions to do so will be dependent upon the virtualization software selected as per the
Selecting your virtual environment recipe. Generally, it will be provided as an ISO image
(the le extension will be .iso). ISO means a compressed disk image, and all virtualization
software that I am aware of will let you mount (attach) an ISO image to the virtual machine as
a CD Drive. This means that when you elect to create a new virtual machine, you will normally
be prompted for the ISO image, and the installation of the operating system should proceed in
a familiar and relatively automated fashion.
So for this recipe, ready means that you have your virtualization software up and running, the
Windows Server 2008 R2 base operating system is installed, and you are able to log in as the
Administrator (and that you are effectively logging in for the rst time).
How to do it
Log in as the Administrator. You will be prompted to change the password the rst time—I
suggest choosing a very commonly used Microsoft password—Password1. However, feel
free to select a password of your choice, but use it consistently throughout this chapter.
The Initial conguration tasks screen will come up automatically. On this screen:
1. Activate windows using your 180 day trial key or using your MSDN key.
2. Select Provide computer name and domain. Change the computer name to a
simpler one of your choice. In my case, I named the machine OPENHIGHWAY. Leave

the Member of option as Workgroup. The computer will require a reboot.
3. In the Update this server section, choose Download and install updates. Click on
the Change settings link and select the option Never check for updates and click
OK. Click the Check for updates link. The important updates will be selected. Click
on Install Updates. Now is a good time for a coffee break! You will need to reboot
the server when the updates complete.
4. In the Customize this server section, click on Add Features. Select the Desktop
Experience, Windows, PowerShell, Integrated, Scripting, and Environment options.
Choose Add Required Features when prompted to do so. Reboot the server when
prompted to do so.
If the Initial conguration tasks screen appears now, or in the future, you may now select
the checkbox for Do not show this window at logon. We will continue conguration from the
Server Manager, which should be displayed on your screen. If not, launch the Server Manager
using the icon on the taskbar.
Do wn lo ad f ro m Wo w! eBook <www.wowebook.com>
Setting Up a Development Environment
12
We return to Server Manager to continue the conguration:
OPTIONAL: Click on Congure Remote Desktop if you have a
preference for accessing your virtual machine using
Remote Desktop
(
RDP) instead of using the virtual machine's console software.
1. In the Security Information section, click Go to Windows Firewall. Click on the
Windows Firewall Properties link. From the dialog, go to each of the tabs, namely,
Domain Prole, Private Prole, and Public Prole and set the Firewall State to
Off on each tab and click OK.
2. Click on the Server Manager node, and from the main screen, click on the Congure
IE ESC link. Set both options to Off and click OK.
3. From the Server Manager, expand the Conguration node and then expand Local

Users and Groups node, and then click on the
Users folder. Right-click on the
Administrator account and select Properties. Select the option for Password never
expires and click OK.
4. From the Server Manager, click the Roles node. Click the Add Roles link. Now, click
on the Introductory screen and select the checkbox for Active Directory Domain
Services. Click Next, again click on Next, and then click Install. After completion,
click the Close this wizard and launch the Active Directory Domain Services
Installation Wizard (dcpromo.exe) link. Now, carry out the following steps:
 From the new wizard that pops up, from the welcome screen, select the
checkbox Use advanced mode installation, click Next, and again click on
Next on the Operating System Compatibility screen.
 Select the option Create a new domain in a new forest and click Next.
 Choose your domain (FQDN)! This is completely internal to your
development server and does not have to be real. For book purposes,
I am using theopenhighway.net, as shown in the following screenshot.
Then click Next:
Chapter 1
13
 From the Set Forest Functional Level drop-down, choose Windows Server
2008 R2 and click Next.
 Click Next on the Additional Domain Controller Option screen. Select
Yes on the Static IP assignment screen. Click Yes on the Dns Delegation
Warning screen.
 Click Next on the Location for Database, Log Files, and SYSVOL screen.
 On the Directory Services Restore Mode Administrator Password screen,
enter the same password that you used for the Administrator account, in my
case, Password1. Click Next.
 Click Next on the Summary screen.
 Click on the Reboot On Completion screen. Otherwise reboot the server

after the installation completes.
5. You will now congure a user account that will run the application pools for the
SharePoint web applications in IIS. From the Server Manager, expand the Roles
node. Keep expanding the Active Directory Domain Services until you see the
Users folder. Click on the Users folder. Now carry out the following:
 Right-click on the Users folder and select New | User
 Enter SP_AppPool in the full name eld and also enter SP_AppPool in the
user logon eld and click Next.
 Enter the password as Password1 (or the same as you had selected for the
Administrator account). Deselect the option for User must change password
at next logon and select the option for Password never expires. Click Next
and then click Finish.
Setting Up a Development Environment
14
6. A loopback check is a security feature to mitigate against reection attacks,
introduced in Windows Server 2003 SP1. You will likely encounter connection issues
with your local websites and it is therefore universally recommended that you disable
the loopback check on a development server. This is done from the registry editor:
 Click the Start menu button, choose Run…, enter Regedit, and click OK to
bring up the registry editor.
 Navigate to HKEY_LOCAL_MACHINE | SYSTEM | CurrentControlSet |
Control | Lsa
 Right-click the Lsa node and select New | DWORD (32-bit) Value
 In the place of New Value #1 type DisableLoopbackCheck.
 Right-click DisableLoopbackCheck, select Modify, change the value to 1,
and click OK
Congratulations! You have successfully congured Windows Server 2008 R2 and are ready
for our next recipe Installing and conguring SQL Server 2008 R2
There's more
The Windows Shutdown Event Tracker is simply annoying on a development machine. To

turn this feature off, click the Start button, select Run…, enter gpedit.msc, and click OK.
Scroll down, right-click on Display Shutdown Event Tracker, and select Edit. Select the
Disabled option and click OK, as shown in the following screenshot:
Chapter 1
15
Installing and conguring SQL Server
2008 R2
SharePoint 2010 requires Microsoft SQL Server as a fundamental component of the overall
SharePoint architecture. The content that you plan to manage in SharePoint, including web
content and documents, literally is stored within and served from SQL Server databases. The
SharePoint 2010 architecture itself relies on information stored in SQL Server databases, such
as conguration and the many service applications. In this recipe, we will install and congure
the components of SQL Server 2008 necessary to install SharePoint 2010.
Getting ready
I do not recommend SQL Server Express for your development environment, although this
is a possible, free, and valid choice for the installation of SharePoint 2010. In my personal
experience, I have valued the full power and exibility of the full version of SQL Server as well
as not having to live with the constraints and limitations of SQL Express. Besides, there is
another little reason too! The Enterprise edition of SQL Server is either readily available with
your MSDN subscription or downloadable as a trial from the Microsoft site.
Download SQL Server 2008 R2 Enterprise from your MSDN subscription, or type in sql server
2008 enterprise R2 trial download into your favorite search engine to download the 180-day
trial from the Microsoft site.
Setting Up a Development Environment
16
For SQL Server 2008 R2 Enterprise, if you have MSDN software, then you will be provided
with an ISO image that you can attach to the virtual machine.
If you download your SQL Server from the Microsoft site as a trial, extract the software (it
is a self-extracting EXE) on your local machine, and then share the folder with your virtual
machine. Finallly, run the

Setup.exe le.
How to do it
Here is your recipe for installing SQL Server 2008 R2 Enterprise. Carry out the following
steps to complete this recipe:
1. You will be presented with the SQL Server Installation Center; on the left side of
the screen, select Installation, as shown in the following screenshot:
2. For the choices presented on the Installation screen, select New installation or
add features to an existing installation.
3. The Setup Support Rules (shown in the following screenshot) will run to identify
any possible problems that might occur when installing SQL Server. All rules should
pass. Click OK to continue:

×