Thursday, December 24, 2009

Custom Auditing In SharePoint

Code download available at: OfficeSpace2008_09a.exe (631 KB)

Browse the Code Online

 Contents

The AuditingDemo Project

Creating a Page to Support Auditing Configuration

Extending the Site Actions Menu

Viewing Audit Log Entries

Viewing Logs on a Per-Item Basis

Many people using SharePoint® technologies don't realize that there is auditing support built directly into the Windows® SharePoint Services (WSS) 3.0 platform. The primary reason this is not well-known is that WSS auditing support is turned off by default, and it cannot be enabled using anything supplied by WSS out of the box. Taking advantage of the WSS auditing infrastructure requires extra code that is not included with WSS.

One simple way to take advantage of WSS auditing support is to use Microsoft® Office SharePoint Server (MOSS) 2007. MOSS provides a user interface (under Site Settings > Configure Audit Settings) that allows a site-collection owner to enable and configure automatic activity event logging. MOSS also provides an audit-reporting facility that reads audit log entries and reports on which users have been engaging in activities, such as reading and writing content, within a specific site collection.

A second approach to using WSS auditing support will appeal to you as a developer. You can build a custom SharePoint solution with Visual Studio® and create a custom application page that allows a site-collection administrator to enable and configure WSS activity event logging. But it's not enough just to turn on automatic activity event logging. It requires more than that. A custom auditing solution targeting WSS must also include some type of user interface so that users can view or report on audit entries that have been added to the WSS audit log.

Two years ago, not long after Microsoft released the first public beta for MOSS 2007, Joanna Bichsel and I published a white paper titled "Item-Level Auditing with SharePoint Server 2007" (msdn.microsoft.com/library/bb397403), along with an accompanying code sample. In this white paper, we discussed many important details about how to program auditing support in WSS. We also covered how MOSS leverages and extends the WSS auditing infrastructure using custom policies and audit report generation.

In this month's column I am going to walk through a new SharePoint solution I recently created with a Visual Studio project named AuditingDemo. The project contains some of the same auditing management code I covered in the white paper, such as the code that enables auditing support through the WSS object model. However, the AuditingDemo project has been totally redesigned and is a much better starting point than the sample code I wrote two years ago. For example, the AuditingDemo project has been created using the STSDEV utility, and I have incorporated many best practices in areas such as solution-package deployment, security programming, and security trimming.

My goal with this month's column is to explain these updated best practices and SharePoint development techniques. It is my intention to complement the original white paper rather than overlap its content. If you have not read the original white paper, I recommend taking a look at it first so that you have a proper context for this month's column.


 

The AuditingDemo Project

The purpose of the AuditingDemo project is to provide a custom SharePoint solution that can take advantage of the auditing support built into the WSS platform. I designed the project around a scenario wherein a site-collection owner (or another user in the role of Audit Manager) can enable, view, and modify audit settings for the current site collection. The AuditingDemo project also provides viewing capabilities so that a user in the role of an auditor can see what's in the audit log to determine what activity has occurred on a site-collection-wide basis and also on a per-item or per-document basis.

As I mentioned earlier, this project was built using the STSDEV utility, which you can download from codeplex.com/stsdev. You can read about it in my March 2008 Office Space column (msdn.microsoft.com/magazine/cc337895).

The AuditingDemo project has been designed with a central feature (also named AuditingDemo) that is scoped to the level of the site collection. To use the AuditingDemo, you simply need to activate the feature once per site collection.

The AuditingDemo feature includes a feature receiver class with a FeatureActivated event handler (see Figure 1). The code inside FeatureActivated executes during feature activation, and it accomplishes two important things. First, it fully enables audit logging for the entire site collection. Second, it creates a few security objects specific to the AuditingDemo solution. In particular, the code inside FeatureActivated creates two new SharePoint groups and two new permission levels that allow the site-collection administrator to add users into the roles of Auditor and Audit Manager.

 Figure 1 The FeatureActivated Event Handler


Copy Code

public override void FeatureActivated(SPFeatureReceiverProperties

properties) {

using (SPSite siteCollection = (SPSite)properties.Feature.Parent) {

SPWeb TopLevelSite = siteCollection.RootWeb;


 

// Turn on auditing flags.

siteCollection.Audit.AuditFlags = SPAuditMaskType.All;

siteCollection.Audit.Update();


 

// create permission levels

SPRoleDefinition AuditorPermissions, AuditManagerPermissions;

AuditorPermissions = CreatePermissionLevel(

"Auditor Permissions",

"Can view audit logs",

"Read");

AuditManagerPermissions = CreatePermissionLevel(

"Audit Manager Permissions",

"Can configure auditing support",

"Design",

SPBasePermissions.ManageWeb);


 

// create Auditors group

SPGroup Auditors = CreateGroup(

"Auditors",

"for users who need to audit user activity");

SPRoleAssignment AuditorRoleAssignment = new SPRoleAssignment(Auditors);

AuditorRoleAssignment.RoleDefinitionBindings.Add(AuditorPermissions);

TopLevelSite.RoleAssignments.Add(AuditorRoleAssignment);


 

// create Audit Managers group

SPGroup AuditManagers = CreateGroup(

"Audit Managers",

"for users who configure WSS auditing support");

SPRoleAssignment AuditManagerRoleAssignment =

new SPRoleAssignment(AuditManagers);

AuditManagerRoleAssignment.RoleDefinitionBindings.Add(

AuditManagerPermissions);

TopLevelSite.RoleAssignments.Add(AuditManagersRoleAssignment);

}

Note that the code in the FeatureActivated event handler calls the two utility methods named CreatePermissionLevel and CreateGroup. The reason I wrote these was to ensure that any preexisting security objects with the same name as those being created were first deleted. Each method then creates the requested security object (permission level or group), adds it to the appropriate collection within the top-level site, and returns a strongly typed security object to the caller. The CreatePermissionLevel method returns an SPRoleDefinition object that represents the new permission level, and the CreateGroup method returns an SPGroup.

Note that I designed the CreatePermissionLevel method with several overloaded implementations that make the third and fourth parameters optional. The third parameter is for passing the name of an existing permission level that is used to make a copy for the new permission level. For example, the AuditorPermissions permission level is created by making a copy of the built-in Read permission level. And the AuditManagerPermissions permission level is created by making a copy of the built-in Design permission level.

The fourth parameter to the CreatePermissionLevel method is of the SPBasePermissions type, which is used to pass one or more extra permissions that are then used to initialize the new permission level. For example, the call to CreatePermissionLevel that creates the SPRoleDefinition object AuditManagerPermissions passes a value of ManageWeb for the fourth parameter. This means that the new permission level is created with the same permissions as the built-in Design permission level plus the ManageWeb permission.

The ManageWeb permission is important because it's required for users who need to adjust audit settings. I will cover two security trimming techniques later in this column that can be used to display menu items to just those users that have this permission.

The CreateGroup method does a little more than add a new group to the top-level site. It also adds the new group to the associated group's collection and adds the ID of the new group into a site-level property named vti_associatemembergroup. This extra code is important if you want the new group to show up in the group's QuickLaunch bar and inside the combobox of the Add Users page, which makes it far more intuitive for the site-collection owner to add users to the new group.


 

Creating a Page to Support Auditing Configuration

The AuditingDemo project provides three custom app pages—AuditConfig.aspx, AuditLogViewer.aspx, and ItemAudit.aspx—that were developed using best-practice techniques. For example, these application pages are deployed within a solution-specific directory named AuditingDemo inside the LAYOUTS directory. The code that provides the behavior for these pages has been written in codebehind files (such as AuditConfig.cs). The codebehind files are then compiled into the project's main assembly, AuditingDemo.dll, which is installed and loaded from the Global Assembly Cache (GAC).

The AuditConfig.aspx application page provides a user interface for configuring WSS auditing support. I added a CustomAction to the AuditingDemo feature so that users with the ManageWeb permission will be presented with a link on a site-settings page that allows them to navigate to AuditConfig.aspx:


Copy Code

<!-- Add Link to Site Setting Page -->

<CustomAction

Id="SiteActionsToolbar"

GroupId="SiteCollectionAdmin"

Location="Microsoft.SharePoint.SiteSettings"

Sequence="0"

Rights="ManageWebs"

Title="Audit Management" >

<UrlAction Url="~sitecollection/_layouts/AuditingDemo/AuditConfig.aspx"/>

</CustomAction>

Note that I created this custom action with a GroupId attribute value of SiteCollectionAdmin and a Sequence attribute value of 0. This is what makes the link show up first in the Site Collection Administration column of the Site Settings page.

The Rights attribute, which I have included with a value of ManageWebs, is used by WSS to provide declarative security trimming. Therefore, only users who have the ManageWebs permission will see this link. This will be the case for site-collection owners as well as any users that the site-collection owner has added to the role of Audit Manager.

When users navigate to AuditConfig.aspx, they see the UI in Figure 2. As you can see, this application page provides radio buttons to fully enable or disable auditing. You will also find a radio button for entering a selective mode where the user can choose exactly what activities are recorded with an audit log entry.



Figure 2 AuditConfig.aspx Lets Users Configure Audit Logging

The code that is behind the OK button of AuditConfig.aspx is pretty simple. It reads which radio button has been selected by the user and sets the audit flags for the current site collection to the appropriate value. Then it calls Update on the Audit property to record the changes into the Content Database:


Copy Code

SPSite siteCollection = this.Site;

if (radAuditingOff.Checked) {

siteCollection.Audit.AuditFlags = SPAuditMaskType.None;

}

if (radAuditingOnFull.Checked) {

siteCollection.Audit.AuditFlags = SPAuditMaskType.All;

}

if (radAuditingOnSelective.Checked) {

siteCollection.Audit.AuditFlags = GetSelectiveAuditingFlags();

}

siteCollection.Audit.Update();

If the user has chosen the option for selective auditing configuration, there is a call to the GetSelectiveAuditingFlags utility method. It inspects all those checkboxes and uses bitwise OR operations to return an SPAuditTypeMask value that represents a combination of all the types of activities that the user has selected for auditing:


Copy Code

private SPAuditMaskType GetSelectiveAuditingFlags() {

SPAuditMaskType AuditFlags = SPAuditMaskType.None;

if (chkAuditView.Checked) {

AuditFlags |= SPAuditMaskType.View;

}

if (chkAuditUpdate.Checked) {

AuditFlags |= SPAuditMaskType.Update;

}

// Repeat for Copy, Move, Delete, Undelete, CheckIn, CheckOut,

// Search, Workflow, SecurityChange, ProfileChange, SchemaChange

return AuditFlags;

}


 

Extending the Site Actions Menu

I've provided navigation support so that users can get to the AuditLogViewer.aspx application page. This is a page designed for users in the role of auditor who want to see what activity has occurred on the site. I decided against putting another link on the Site Settings page because many of the users in the role of auditor may not necessarily be administrators and therefore may never go to the Site Settings page for any other reason. Therefore, adding navigation support using the custom Site Actions menu items seemed more intuitive. It also gives me a chance to show you how to create a flyout menu with programmatic security trimming.

When you want to build a menu item dynamically, you need to create a custom control class and also add a declarative CustomAction element to instantiate an instance of the control class in the correct place. Note how the following CustomAction element differs from the one I showed earlier:


Copy Code

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<!-- Add Command to Site Actions Dropdown -->

<CustomAction Id="AuditingSupport"

GroupId="SiteActions"

Location="Microsoft.SharePoint.StandardMenu"

Sequence="1000"

ControlClass="AuditingDemo.SiteActionsCustomSubMenu"

ControlAssembly="AuditingDemo, [4-part name]"

Title="Auditing Support"

Description="Support for configuring and viewing auditing" />

</Elements>

The main difference with this CustomAction element is that it has been declared using a ControlClass attribute and a ControlAssembly attribute instead of a UrlAction element. This makes it possible to generate menu items dynamically using a custom control class such as the SiteActionsCustomSubMenu, which is used in the AuditingDemo project and is shown in the code in Figure 3. Note that a custom control class must inherit from the WebControl class supplied by the ASP.NET programming model.

 Figure 3 SiteActionsCustomSubMenu


Copy Code

public class SiteActionsCustomSubMenu : WebControl {


 

protected override void OnLoad(EventArgs e) {

this.EnsureChildControls();

base.OnLoad(e);

}


 

protected override void CreateChildControls() {

SPSite siteCollection = SPContext.Current.Site;

SPWeb site = SPContext.Current.Web;

SPUser user = site.CurrentUser;

// provide security trimming

if (IsCurrentUserInGroup("Auditors") ||

IsCurrentUserInGroup("Audit Managers") ||

user.IsSiteAdmin) {

string siteCollectionPath = siteCollection.Url;

if (!siteCollectionPath.EndsWith(@"/"))

siteCollectionPath += "/";


 

SubMenuTemplate smt = new SubMenuTemplate();

smt.Text = "Auditing Support";

smt.ID = "mnuAuditingSupport";

smt.Description = "Configure and View Auditing";

smt.ImageUrl = siteCollectionPath +

@"_layouts/images/AuditingDemo/AfricanPith32.gif";

smt.Sequence = 400;


 

MenuItemTemplate mit1 = new MenuItemTemplate();

mit1.ID = "mnuAuditLog";

mit1.Text = "Audit Log";

mit1.Description = "Inspect Audit Entries";

mit1.Sequence = 401;

mit1.ClientOnClickNavigateUrl = siteCollectionPath +

"_layouts/AuditingDemo/AuditLogViewer.aspx";

mit1.ImageUrl = siteCollectionPath +

@"_layouts/images/AuditingDemo/Binoculars32.gif";

// add menu item to Controls collection

smt.Controls.Add(mit1);

// perform extra security trimming for menu for AuditConfig.aspx

if (IsCurrentUserInGroup("Audit Managers") || user.IsSiteAdmin) {

MenuItemTemplate mit2 = new MenuItemTemplate();

mit2.ID = "mnuAuditingConfiguration";

mit2.Text = "Auditing Configuration";

mit2.Description = "Enable/Disable Auditing";

mit2.Sequence = 402;

mit2.ClientOnClickNavigateUrl = siteCollectionPath +

"_layouts/AuditingDemo/AuditConfig.aspx";

mit2.ImageUrl = siteCollectionPath +

@"_layouts/images/AuditingDemo/Compass32.gif";

smt.Controls.Add(mit2);

}


 

this.Controls.Add(smt);

}

}


 

private bool IsCurrentUserInGroup(string GroupName) {

SPWeb site = SPContext.Current.Web;

foreach (SPGroup group in site.SiteGroups) {

if (group.Name.Equals(GroupName)) {

return group.ContainsCurrentUser;

}

}

throw new ApplicationException("There is no group named " +

GroupName);

}

}

The CreateChildControls method provides dynamic security trimming. Note that the entire flyout menu is only shown to users who are either site-collection owners or who have been added to the Auditors or Audit Manager groups. The second menu item, which allows a user to navigate to the AuditConfig.aspx page, is further trimmed to exclude users in the Auditors group. This menu is only displayed to site-collection owners or users who have been added to the Audit Manager group.

There is one more important point I want to make about creating a dynamic menu with a custom control class. Like a Web Part, a custom control class requires a SafeControl entry in the web.config file of the hosting Web application. Here, the STSDEV utility provides the support for adding this SafeControl. It adds the appropriate elements into the manifest.xml file, and, as a result, the required SafeControl entry is automatically added to one or more web.config files whenever the AuditingDemo.wsp solution package is deployed within a farm.


 

Viewing Audit Log Entries

The AuditingDemo solution provides the AuditLogViewer.aspx custom application page shown in Figure 4. This page provides the users with a view of all the audit entries for the entire site collection. There is also a button on this page with the caption Clear Audit Log. This button is security trimmed so it is only shown to site-collection owners. The code behind this button deletes all entries from the audit log, which you might find to be helpful while testing a custom auditing solution.



Figure 4 AuditLogViewer.aspx Displays Audit Log Entries

The code behind AuditLogViewer.aspx uses an SPAuditQuery object to query the audit log of the current site collection. A query is run by calling the GetEntries method on the Audit property of an SPSite object. A call to GetEntries returns an SPAuditEntryCollection object that can be enumerated to inspect each audit entry as an SPAuditEntry object:


Copy Code

SPSite SiteCollection = SPContext.Current.Site;

SPAuditQuery wssQuery = new SPAuditQuery(SiteCollection);

SPAuditEntryCollection auditCol =

SiteCollection.Audit.GetEntries(wssQuery);

foreach (SPAuditEntry entry in auditCol) {

// enumererate through each audit entry

}

There are many ways in which you can enumerate through an SPAuditEntryCollection to create a display. I used a technique where I dynamically create an ADO.NET DataTable object and then populate it with one row of information per audit entry. By creating a DataTable, it becomes relatively simple to display the audit information by binding it to an SPGridView control.

The code behind the AuditLogViewer.aspx page must deal with a special security concern. If you examine the code that queries the audit log, you will see that it first makes a call to RunWithElevatedPrivileges so that it can run under the identity of the privileged SHAREPOINT\System account. Using this technique is required because querying the audit log is a privileged operation.

There will likely be scenarios where a user is added into the role of Auditor, but this user will not be granted the permissions that are necessary in order to query the audit log. Therefore, a call to RunWithElevatedPrivileges allows your code to query the audit log, even if the current user does not have the required permissions to do so.


 

Viewing Logs on a Per-Item Basis

The third application page in the AuditingDemo project is ItemAudit.aspx. This page shows audit entries for one particular item or document. Navigation to this page is provided by adding a CustomAction element that adds a new EditControlBlock (ECB) menu item to the built-in Item content type:


Copy Code

<CustomAction Id="ItemAuditing.ECBItemMenu"

RegistrationType="ContentType"

RegistrationId="0x01"

ImageUrl="/_layouts/images/GORTL.GIF"

Location="EditControlBlock"

Sequence="300"

Title="View Audit History">

<UrlAction Url=

"~site/_layouts/AuditingDemo/ItemAudit.aspx?ItemId=

{ItemId}&amp;ListId={ListId}"/>

</CustomAction>

A CustomAction configured for the Item content type will also apply to any content types that inherit from Item. And since all content types inherit from the Item content type, this technique will effectively add an ECB menu item to every item and document across the entire site collection.

You can test this technique out by downloading the AuditingDemo sample code and then deploying it within the farm on a SharePoint development machine. Once you have completed activation of the AuditingDemo feature in a particular site collection, you will see that every item and document now has an ECB menu item with a View Audit History title. Whenever a user selects that ECB menu item, he is redirected to the ItemAudit.aspx page, as shown in Figure 5.



Figure 5 ItemAudit.aspx Displays Audit Entries for a Particular Item

Like the AuditLogViewer.aspx page, the code behind ItemAudit.aspx uses an SPAuditQuery object to retrieve audit log data as well as a DataTable that is populated with audit log entry data and then bound to an SPGridView control. The main difference is that the code behind ItemAudit.aspx makes a call to the RestrictToListItem method of the SPAuditQuery object before running the query to filter the results so that they only pertain to the item or document in question.

It's important to note that the SPAuditQuery class also provides two additional filtering methods, RestrictToList and RestrictToUser, so that you can see audit entries for a particular list or a particular user. Also note that you can use the RestrictToUser together with either the RestrictToListItem method or the RestrictToList method to determine what a specific user has been doing with either a list or a list item.


 

Send your questions and comments for Ted to mmoffice@microsoft.com.


 

Ted Pattison is an author, trainer, and SharePoint MVP who lives in Tampa, Florida, and has just completed his book Inside Windows SharePoint Services 3.0 for Microsoft Press. He also delivers advanced SharePoint training to professional developers through his company, Ted Pattison Group (www.TedPattison.net).


 

Wednesday, December 9, 2009

Useful Sharepoint Links

Useful Links

 
 

MOSS Video Demos (Total 14 Modules)

Before You Begin with SharePoint Server 2007

MOSS Tools for performance and capacity planning

Downloadable book: Planning and architecture for Office SharePoint Server 2007

MOSS 2007 - Planning and Architecture for Office SharePoint Server 2007

MOSS 2007 - Administrator Guide

Complete reference of all STSADM operations

Using the 2007 Microsoft Office system for disaster planning and response

Planning and Designing SharePoint Products and Technology Solutions for Geographically Dispersed Sites

Complete reference of all STSADM operations

Complete reference of all PSCONFIG operations

 
 

Best Practices

 
 

Before You Begin with SharePoint Server 2007

Best Practices Analyzer for WSS 3.0 and MOSS2007

Writing SQL Syntax Queries for Relevant Results in MOSS2007

Backing Up and Restoring Web Sites with Stsadm

Downloadable book: Planning and architecture for Office SharePoint Server 2007

MOSS Hardware and Software Requirements

SharePoint 2007 products comparison download

Which SharePoint technology is right for you?

White Paper: Working with large lists in Office SharePoint Server 2007

MOSS Tools for performance and capacity planning


 

How to Deploy updates for SharePoint 2007

 
 

Deploy software updates for Windows SharePoint Services 3.0

Deploy software updates for Office SharePoint Server 2007

How to troubleshoot common errors that occur when you run the SharePoint Products and Technologies Configuration Wizard

 
 

How to configure Alternate Access Mappings (AAM) successfully

http://sharepoint.microsoft.com/blogs/fromthefield/Lists/Posts/Post.aspx?ID=8

 
 

What every SharePoint administrator needs to know about Alternate Access Mappings

 
 

http://blogs.msdn.com/sharepoint/archive/2007/03/06/what-every-sharepoint-administrator-needs-to-know-about-alternate-access-mappings-part-1.aspx

http://blogs.msdn.com/sharepoint/archive/2007/03/19/what-every-sharepoint-administrator-needs-to-know-about-alternate-access-mappings-part-2-of-3.aspx

http://blogs.msdn.com/sharepoint/archive/2007/04/18/what-every-sharepoint-administrator-needs-to-know-about-alternate-access-mappings-part-3-of-3.aspx


 

STSADM COMMANDS

 
 

Jose Barreto's Blog Complete reference of all STSADM operations (with parameters) in MOSS 2007 SP1

Jose Barreto's Blog Complete reference of all STSADM operations (with parameters) in MOSS 2007

 
 

SharePoint Administration Toolkit

SharePoint Administration Toolkit (Office SharePoint Server)

 
 

TCP Chimney should be disabled

 
 

http://support.microsoft.com/kb/942861

The Microsoft Windows Server 2003 Scalable Networking Pack release

Thursday, December 3, 2009

Best Blogs List

http://blog.thekid.me.uk/default.aspx?PageIndex=2

http://blogs.msdn.com/brianwilson/

My current SharePoint development toolkit

My current SharePoint development toolkit

Tuesday, December 1, 2009

SharePoint Menus in C#

SharePoint Menus in C#

No-code SharePoint Menus

No-code SharePoint Menus

SharePoint Object Model Best Practices

Found here on MSDN.

Free 3rd Party Web Parts for SharePoint

http://www.shareesblog.com/?p=134

SqlDataReader, DataTable and Multiple Resultsets

SqlDataReader, DataTable and Multiple Resultsets

15 Minute Intro to SharePoint Branding

Yaroslav has a great intro webcast to SharePoint branding and also demonstrates the FireBug add-in to FireFox.

13 articals on SharePoint Deployment and Solution

SharePoint 2007 Deployment Series

List of development tools for SharePoint Server 2007

Comprehensive List of development tools for SharePoint Server 2007

Thursday, November 26, 2009

Configuring Multiple Authentication Providers for SharePoint 2007


 

Windows SharePoint Services (WSS) V3 contains several new features around authentication and authorization that make it easier to develop and deploy solutions in Internet facing environments, especially extranets. In the previous version of WSS, all security principals needed to resolve at some point to a Windows identity – either a user account or group. WSS V3 is built upon the ASP.NET 2.0 Framework, which allows the use of forms-based authentication (FBA) to authenticate users into the system. By riding on top of ASP.NET 2.0's pluggable authentication provider model, you can now support users stored in Active Directory as well as SQL Server, an LDAP directory, or any other directory that has an ASP.NET 2.0 Membership provider. Although WSS V3 will not ship with any Membership providers, Microsoft Office SharePoint Server (MOSS) 2007 will include an LDAP V3 Membership provider, and ASP.NET 2.0 includes a SQL Server provider. But if you want to use a directory and can't find a Membership provider for it, you can write your own! This is a key technology enabler for heterogeneous environments.


 

In a typical extranet environment, content will have two points of access: one on the intranet for employee use and the other on the extranet, where trusted partners can access specific sites, lists and libraries or individual items. Listed below are the WSS V3 features that support this scenario -- some are new while others are just terminology changes:

         Web Application: A web application is what was called a virtual server in the previous version of SharePoint. A single web application only supports a single authentication provider, such as Windows, Forms, etc.

         Zones: A zone is a way to map multiple web applications to a single set of content databases. It is also can be a division of authentication providers. For example, you can create a new web application, create a content database and configure it to use Windows authentication. You can then create a second web application and map it to the first. When you do that you need to assign a zone with which the second web application is associated, such as Intranet, Internet, Custom, or Extranet. The second web application can also use a completely different authentication mechanism, such as forms.

         Policies: A policy is useful in a number of different scenarios, including configuring a web application for forms authentication. It allows you to create policies to grant full access, read only access, deny write access or deny all access to a user or group on a web application. This policy grant applies to all sites in the web application, and it overrides any permissions established within individual sites, lists or items.

         Alternate Access Mappings: In the previous version of SharePoint, it wasn't as important in an extranet scenario to create an alternate access mapping (AAM) because SharePoint would look to IIS to get some of that information. In WSS V3, it's imperative to use AAM or things just flat out won't work. AAM is a way to define the different URL namespaces that are associated with a set of content databases. It effectively manages the zones relationship described above.

         Authentication Providers: So far I've described how WSS V3 uses the ASP.NET 2.0 pluggable authentication provider model using the Membership provider interface. As well, SharePoint also supports the Role provider interface, which enables you to surface attributes, such as group membership, about your users as well.


 

At a high level, creating an extranet solution in WSS V3 requires you to do the following steps. I'll walk through them briefly and then dive into more detail below. Since MOSS 2007 is built on top of WSS V3, all of the information below applies to MOSS as well. For this scenario, assume that you want to have an intranet style site used internally by your corporate users. They are all joined to your corporate Active Directory. In addition, you have a number of trusted partners to which you wish to give access via the Internet. Note that in this scenario I will not be touching on any aspects of securing your site with firewalls, proxy servers, segmented networks, DMZ Active Directory designs, security best practices around farm configuration, etc. You can read all about that in Joel's recent blog entry here: http://blogs.msdn.com/sharepoint/archive/2006/08/08/691540.aspx.


 

The process you would go through to build out such a site would be as follows.

  1. After installing WSS V3 (or MOSS 2007) and having configured all of the services and servers in the farm, create a new web application. By default this will be configured to use Windows authentication and will be the entry point through which your intranet users will access the site. We'll refer to this site as http://intranet. Next, create a second web application. When you create the web application, select the option to Extend an existing Web Application. When you create your second web application, map it to the Extranet zone. Give it a Host Header name that you will configure in DNS for your extranet users to resolve against. We'll refer to this site as http://extranet.contoso.com.

  2. If you haven't created and populated your directory of FBA users who will be accessing the site via the extranet, then you should do so at this time. For this scenario we'll assume that you are using FBA with the SQL Server Membership and Role providers that are included with ASP.NET 2.0.

  3. Manually modify the web.config for the extranet site and add in the information about your Membership and Role provider (the Role provider is technically optional, but most implementations will use it). Add this same information into the web.config for the Central Administration site. Save both config files and do an IISRESET.

  4. In the Central Admin site, go to the Application Management page and select the Policy for Web Application link. Add a user from your SQL Server directory to the Extranet zone for your web application. You should be able to type in the user name and resolve it, or use the People Picker dialog to search and find the user name. If everything is configured correctly then SharePoint will be able to resolve the user name you add. Give the user account Full access to the web application.

  5. Navigate to the site using either entry point -- Windows or Forms-based authentication. If you use FBA, then you will need to sign in with the credentials of the user that was granted full access rights via policy. After you navigate to the site, go into Site Settings, People and Groups. From there you can add both Windows and forms users and groups to SharePoint Site Groups. Your users should now be able to access the site.


 

Now let's look at some of the above steps in more detail. Creating the web applications should be fairly straightforward using Central Administration, so I won't spend any time on that. The key takeaway here is that when you create the second web application, you need to make sure that you select the option to Extend an existing Web Application and map it to the Extranet zone. Also remember to give it a Host Header name that is in your external DNS – this is the URL that external users will use to access the site via the Internet.


 

Next, you need to create the aspnetdb database used for storing membership and role information if you don't have one already set up. To create the database, do the following:

  1. Open a command prompt and change to the .NET Framework directory (by default, it's C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727).

  2. Run the following command: aspnet_regsql -A all –E

  3. This will create the aspnetdb database on the local SQL Server. If you wish to install it on a different server, then run aspnet_regsql /? to determine the appropriate switch to use.

If you are creating your SQL Server provider database for the first time you will also need to create one or more users and optionally, one or more roles. These will be the security principals that you add to the Policy for the extranet web application as well as the SharePoint Site Groups. There are multiple ways to do this and a quick search on the web will highlight some of those tools and methods. That's a bit out of scope for this already lengthy blog, so I'll continue on and assume that you've already created the users and roles for your SharePoint site.


 

Now we have our web applications as well as users and roles created in SQL Server, so we need to configure the web.config for the extranet and Central Administration web applications. The first step is to look for a connectionStrings element; if it doesn't exist then you can add it below the </SharePoint> and above the <system.web> elements. The new element should look like the following:


 

<add name="AspNetSqlProvider" connectionString="server=yourSqlServerName; database=aspnetdb; Trusted_Connection=True" />


 

You'll want to take note of the name attribute above, because you will use that attribute name when configuring the Membership and Role providers. Add that information as follows:


 

  1. Open the web.config file for your extranet web application in a text editor such as Notepad.

  2. Add your connectionString element described above as the last item in the connectionStrings section in the web.config file.

  3. Add the Membership and Role configuration information to the web.config file. It must be added below the <system.web> element and should look like the following:

    <membership defaultProvider="AspNetSqlMembershipProvider">

    <providers>

    <remove name="AspNetSqlMembershipProvider" />

    <add connectionStringName="AspNetSqlProvider" passwordAttemptWindow="10" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" description="Stores and retrieves membership data from the Microsoft SQL Server database" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    </providers>

    </membership>

     
     

    <roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">

    <providers>

    <remove name="AspNetSqlRoleProvider" />

    <add connectionStringName="AspNetSqlProvider" applicationName="/" description="Stores and retrieves roles data from the local Microsoft SQL Server database" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    </providers>

    </roleManager>

  4. Save and close the web.config file.

The name attributes of the Membership and Role providers are highlighted above. You need to note what these names are because you will enter them in Central Administration when you configure FBA for the site.


 

You also need to make the same exact changes to the web.config for the Central Administration site, with one minor exception. The roleManager element for the extranet web application looks like the following:

<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">


 

You need to change this line to read as follows:

<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">


 

This change is necessary because the Central Administration site still uses Windows authentication for the role provider -- that's why the AspNetWindowsTokenRoleProvider is set as the default provider.


 

Now you need to configure the Authentication provider for the extranet web application to use FBA. Open your browser and navigate to your farm's Central Administration site, click on Application Management and then on Authentication Providers. Make sure that you are working on the web application for which you wish to enable FBA. (If the correct application is not already pre-selected, click the Change button in the upper right hand corner of the page to select the application.)


 

You should see a list of two zones that are mapped for this web application; both should say Windows. Click on the link that says Windows for the web application in the Extranet zone and do the following:

  1. In the Authentication Type section, click on the Forms radio button. The page will post back and expose two new edit boxes.

  2. In the Membership provider name edit box, type in the name of your web application's Membership provider for the current zone. That is the value that was highlighted in the defaultProvider attribute of the Membership element above.

  3. In the Role manager name edit box, type in the name of your web application's Role provider. That is the value that was highlighted in the defaultProvider attribute of the roleManager element above.

  4. Click the Save button.

Your extranet web application is now configured to use FBA. However, until users, who will be accessing the site via FBA, are given permissions for the site, it will be inaccessible to them. To do this, you could go directly to the default zone (i.e. http://intranet) of the site, login with your Windows credentials, and add the FBA users. However, I'll describe an alternative approach because it's the one that you are most likely to use if you ever configure an application that only has one web application, which uses FBA.


 

To get started, open your browser and navigate to your farm's Central Administration site. Click on Application Management and then click on Policy for Web Application. Make sure that you are working on the extranet web application. Do the following steps:

  1. Click on Add Users.

  2. In the Zones drop down, select the appropriate Extranet zone. IMPORTANT: If you select the incorrect zone, you may not be able to resolve user names. Hence, the zone you select must match the zone of the web application that is configured to use FBA.

  3. Click the Next button.

  4. In the Users edit box, type the name of the FBA user whom you wish to have full control for the site.

  5. Click the Resolve link next to the Users edit box. If the web application's FBA information has been configured correctly, the name will resolve and become underlined.

  6. Check the Full Control checkbox.

  7. Click the Finish button.


 

That's it -- that's all of the configuration needed! You can now navigate to either web application: http://intranet or http://extranet.contoso.com. Irrespective of which entry point you use, you can add, search and resolve both Windows and FBA users and groups and add them to SharePoint Site Groups. The People Picker is smart enough to know about all of the web applications that are mapped to the site and will try all of the authentication providers that those applications use.


 

Lastly, there are two other things for you to remember:

  1. Resolving group names: The People Picker can only do wildcard searches for Windows group names. If you have a SQL Role provider group called "Readers" and enter "Read" in the People Picker search dialog, it will not find your group; if you enter "Readers" it will. This is not a bug -- the Role provider just doesn't provide a good way to do wildcard group searching.

  2. Use Policies sparingly: The concept described above for adding a user or group via the web application Policy should only be used to provide a way for an FBA administrator to access the site. Policies are very coarsely grained compared to the fine grain permissions that can be configured and granted within individual sites, lists and items. Once you've added your site administrator via Policy, all other users and groups should be added from within the site itself.


 

Admittedly, there are many steps involved in configuring multiple authentication providers for SharePoint, but I hope that by having read this blog entry, you now understand the reasoning behind each of the steps involved and are in a better position to implement or troubleshoot this particular SharePoint configuration.


 

Alternate-Access-Mappings

alternate-access-mappings-part-1

alternate-access-mappings-part-2

alternate-access-mappings-part-3

Tuesday, November 24, 2009

SharePoint Site Migration Manager Supported Features

Last Updated: September 9, 2009 SSMM Build: 3.6.25

Migration Feature

Support Status

Service Install

List Migration

Supported

  

Metadata Migration

Supported (more...)

Yes

Document Libraries

Supported

  

Document Library and List Version History

Supported (more...)

Yes

Alerts

Supported (more...)

Yes

List Items with Attachments

Supported

  

Mapping List Names During Migration

Supported

  

Global Navigation

Supported (more...)

Yes

Incremental Migration

Supported

  

Incremental Migration by Date

Supported

  

Form Libraries

Supported

  

Issues Lists

Supported (more...)

  

Audiences

Supported (more...)

  

Surveys

Supported

Yes

List Properties

Supported

  

Discussion Boards

Supported

Yes

Calendars and Events

Supported

  

User Created Document Library Views and List Views

Supported (more...)

  

Personal Views

Unsupported

  

Link Lists (with the option to update URLs)

Supported

  

Image Libraries

Supported

  

Split Lists/Libraries or Consolidate

Supported

  

Migration of List/Library Items to New Target Lists/Libraries

Supported

  

Pages Library Versions

Comming Soon!

  

E-mail Enabled Document Libraries

Supported

Yes

Preserving and Updating Document Approval status

Supported

Yes

List Export to File System

Supported

  

Renaming Lists During Migration

Supported

  

Column Mapping During Migration

Supported (more...)

  

Remove Columns During Migration

Supported

  

Filtered List Migration

Supported

  

Custom Lists

Supported

  

Content Types

Supported (more...)

  

Custom Site Columns

Supported (more...)

  

Find/Replace on List/Library Column Data

Supported

  

Portal Listings

Supported

  

Folders

Supported (more...)

  

Subfolders

Supported

  

Items

Supported

  

Filtered List Item Migration

Supported

  

Look Up fields

Supported

  

Workflows

Unsupported

  

Pending Issue Item

Unsupported

  

User Migration

Supported (more...)

  

User Mapping Across Active Directory Domains

Supported (more...)

  

List Security

Supported

  

Security Groups

Supported (more...)

  

Library Security

Supported

  

Site Security

Supported

  

Sub-site Security

Supported

  

Item Security

Unsupported

  

Roles

Supported

  

Site Migration

Supported

  

MySites

Supported (more...)

Yes

Filtered MySites Copying

Supported (more...)

Yes

Publishing Sites

Supported (more...)

  

Publishing Web Pages

Supported

Yes

Wikis

Supported

  

Blogs

Supported

  

Multi-tabbed Meeting Workspaces

Supported (more...)

  

Recurring Meeting Workspaces

Supported (more...)

  

Site Collection Browsing

Supported (more...)

Yes

Site Collection Creation

Supported

Yes

Site Collection Copying

Supported

Yes

Site Promotion to Site Collection

Supported

Yes

Bucket Web Link Correction

Supported (more...)

  

Custom Templates

Supported (more...)

  

Template Mapping

Supported (more...)

  

Master Pages

Supported

  

Web Parts

Supported (more...)

  

Web Part View Customizations

Supported (more...)

  

SharePoint Server Site Viewer

Supported

  

Batch Copy

Supported

  

Migration Activity Logging

Supported

  

Command Line Execution

Supported

  

Note: The "Service" column indicates whether the features require installing the Metalogix Extensions Service (the service ships with SharePoint Site Migration Manager). Most features that use the service require that it to be installed on the target SharePoint server.

Metalogix SharePoint Site Migration Manager will copy the default.aspx page, as well as all non-web part page files that are stored on the root of a SharePoint site.

Your input is valuable to us. If you have a feature suggestion or request, please e-mail them to support@metalogix.com.

Comments

Metadata
You can copy documents and many types of list items to a target machine that does not have the Metalogix service installed, but the four edit information fields will not be preserved. The four edit information fields are:
Created: The date and time that the list item was created.
Modified: The date and time that the list item was last modified.
Created By: The user who created the list item.
Modified By: The user who last modified the list item.
back to table

Document Library and List Version History
Versions of custom list items are now supported when migrating from Microsoft Office SharePoint Server (MOSS) 2007 to MOSS 2007. Versions of documents in document libraries are also supported. The number of versions to migrate can also be set, so that the last "x" number of versions will migrate.
back to table

Alerts
Alerts may only be copied to MOSS 2007 sites. Site users who have alerts copied over will receive email notification(s) that the copied alert(s) have been created on the target site. Weadvise that alerts not be copied to lists/libraries that have been modified/created within five minutes of the alert copy. Doing so increases the risk that users will receive unnecessary alert e-mails pertaining to the list modifications made prior to the alert-copy. This feature requires that the latest version of the extension service be running on both the source and target servers. The evaluation version of SharePoint Site Migration Manager cannot alerts.
back to table

Global Navigation
SharePoint Site Migration Manager can copy both the Global Navigation (the top bar navigation) as well as the Quick launch navigation. We recommend copying the navigation after the content has been migrated because, in some instances, areas of the site can have their navigation copied before the rest of the site, resulting in incorrect navigation. Performing the navigation cope after the site copy eliminates this issue. This requires the latest version of the extension service running on both the source and target servers.
back to table

Issue Lists
When copying an Issue list that has versioning, the content approval settings of each list item will be set to "Pending," and all approver comments will be retained. If versioning is not turned on for Issue lists then the "Approved" and "Pending" status of items will be preserved, however, any "Rejected" items will have their status changed to "Pending." Once Issue lists are copied user won't be able to migrate and new or modified items to the list, or append items to it. The Issue list would have to be copied again using the "Overwrite existing lists" option.
back to table

Audiences
Audience settings of SharePoint V2 web parts can be mapped when they are being copied to MOSS 2007. MOSS 2007 audience settings are also mapped.
back to table

User Created Document Library Views and List Views
Calendar views need to be manually configured.
back to table

Content Types
SharePoint Site Migration Manager will associate custom content types if they have been created on the target server.
back to table

Custom Site Columns
SharePoint Site Migration Manager does support the copy and creation of custom site columns, but only has this ability at the item level. It is possible to add a column to the Base Columns group with this ability, however, users should be very careful when doing so, as they can be extremely difficult to remove, and these added columns can impact the target server greatly. It is also possible to migrate site column contents, above the item level. However,the custom site columns must first be created on the target server or site, then SSMM can then map and migrate the content of these custom columns.
back to table

Column Mapping
Column mapping is available during item-level copy operations -- other options are coming soon.
back to table

Folders
Folders created under MOSS 2007 Custom Lists are now supported. Folder Metadata can also be migrated, but the four main Metadata edit information fields (Created, Created By, Modified, Modified By) will not be preserved unless the Metalogix Extension Service is installed. It is also possible to map columns during a Folder level migration.
back to table

Users
If the SIDs do not match, SharePoint Site Migration Manager will attempt to map by string. Migrating all user information from MOSS 2007 to MOSS 2007 requires having the Metalogix service on both the source and target servers.
back to table

Cross Domain Users
If you want to migrate users across domains without a trust, please contact Metalogix for more information.
back to table

Security Groups
When migrating from SPS 2003 to MOSS 2007, site groups will map to MOSS permissions and cross site groups will map to MOSS security groups. Permission levels can also be migrated, either seperately as a pre-migration step, or as a part of a site or site collection migration.
back to table

MySites
MySite copying requires the Metalogix service on the target and source servers.
back to table

Publishing Sites
Master pages are now supported.
back to table

Multi-tabbed Meeting Workspaces
Migration of custom tabs in multi-tabbed meeting workspaces is supported. SharePoint Site Migration Manager migrates Web Parts on the default tabs.
back to table

Recurring Meeting Workspaces
Recurring meeting workspaces based off of recurring calendar items, must be re-created manually in order to get the left-side date navigation. Content can be migrated over accurately.
back to table

Site Collection Browsing
Source-side site collection browsing is supported if the Metalogix SharePoint Extensions Service is installed and running on the source server.
back to table

Bucket Web Link Correction
This is supported as a site copy option, and works in almost all cases. However, there are a few exceptions (e.g., bucket web links inside content editor web parts).
back to table

Custom Templates
This includes conversion to custom site definitions.
back to table

Template Mapping
SharePoint 2003 custom/default site templates can be mapped to SharePoint 2007 custom/default templates.
back to table

Web Parts
Custom (third-party) Web Part binaries must be installed on the target server prior to migration.
back to table

Web Part View Customizations
SSMM will preserve list view web part views when copying web parts. SharePoint Site Migration Manager cannot preserve view type, but this is a rare case (e.g., with calendar views that are not common).
back to table