17 Oct 2011

Database does not have a valid owner


Error Message:

“Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects. "

“Database diagram support objects cannot be installed because this database does not have a valid owner.”


USE [<DatabaseName>]
EXEC dbo.sp_changedbowner @loginame = N'sa', @map = false

jQuery disable and enable an element


To Disable:

$('#elementID').attr('disabled', 'disabled');

To Enable:



15 Oct 2011

SQL Server Dynamic SQL commands Execute


Using EXEC

With this approach you are building the SQL statement on the fly and can pretty much do whatever you need to in order to construct the statement.  Let's say we want to be able to pass in the column list along with the city. 

For this example we want to get columns CustomerID, ContactName and City where City = 'London'.

As you can see from this example handling the @city value is not at straight forward, because you also need to define the extra quotes in order to pass a character value into the query.  These extra quotes could also be done within the statement, but either way you need to specify the extra single quotes in order for the query to be built correctly and therefore run.

DECLARE @sqlCommand varchar(1000)
DECLARE @columnList varchar(75)
DECLARE @city varchar(75)
SET @columnList = 'CustomerID, ContactName, City'
SET @city = '''London'''
SET @sqlCommand = 'SELECT ' + @columnList + ' FROM customers WHERE City = ' + @city
EXEC (@sqlCommand)



With this approach you have the ability to still dynamically build the query, but you are also able to still use parameters as you could in example 1. This saves the need to have to deal with the extra quotes to get the query to build correctly.  In addition, with using this approach you can ensure that the data values being passed into the query are the correct datatypes.

DECLARE @sqlCommand nvarchar(1000)
DECLARE @columnList varchar(75)
DECLARE @city varchar(75)
SET @columnList = 'CustomerID, ContactName, City'
SET @city = 'London'
SET @sqlCommand = 'SELECT ' + @columnList + ' FROM customers WHERE City = @city'
EXECUTE sp_executesql @sqlCommand, N'@city nvarchar(75)', @city = @city

2 Oct 2011

LINQ to SharePoint


  • LINQ stands for Language Integrated Query
  • SharePoint works on top of Microsoft .NET Framework 3.5, not .NET 4.0
  • LINQ provides a methodology that simplifies and unifies the implementation of any kind of data access.
  • It facilitates the implementation of several existing architectures for accessing data
    • RAD/prototype
    • Client/server
    • N-tier
    • Smart client
  • LINQ includes many providers suitable for accessing several different types of data sources, few are:
    • LINQ to Objects
    • LINQ to SQL
    • LINQ to Entities
    • LINQ to DataSet
    • LINQ to XML
  • With LINQ you can use the same query syntax over different models.
  • When using LINQ to SharePoint, the query provider generates a CAML query that will be executed against the target SPList using the standard Server Object Model querying syntax.
  • image

  • The key feature of LINQ to SharePoint is that it can query SharePoint data with a fully-typed approach
  • SPMetel.exe automatically generate entities for you
  • it is good practice to use LINQ to SharePoint only against sites that have a well-defined and stable structure.


Limitations of LINQ to SharePoint and CAML queries:

  • The LINQ to SharePoint query provider has some limitations, due to its use of CAML queries under the covers. For example, with CAML, you cannot query more than one list at a time, so you can’t use a group join.
  • LINQ to SharePoint does not support multi-fetch queries that query across multiple lists, or join clauses on fields other than Lookup fields.
  • You cannot define queries across multiple websites or that query different DataContext instances.
  • You cannot use mathematical functions, because CAML does not support them.


Complete list of unsupported syntax and commands, please refer to MSDN http://msdn.microsoft.com/en-us/library/ee536585.aspx

Server Object Model SharePoint


SharePoint Server Object Model hierarchy:

  • SPFarm
    • SPService
      • SPWebApplication
        • SPSite
          • SPWeb
            • SPList
            • SPWeb
              • SPList
          • SPWeb
            • SPList



  • Manage entire SharePoint Server Farm
  • Microsoft.SharePoint.Administration namespace
  • You can connect to an existing Farm, or create a new Farm
  • Important Methods:
    • Create
    • Open
      public static SPFarm Open(SqlConnectionStringBuilder connectionString, SecureString passphrase)
  • Important Properties
    • Servers : to enumerate all the physical servers that belong to the Farm as objects of type SPServer
    • Services : has the type SPServiceCollection and contains different kinds of services, all sharing a common base class of type SPService
      • SPWindowsService,
      • SPWebService.



SPSite Constructor with max parameters:

public SPSite(Guid id, SPUrlZone zone, SPUserToken userToken);

List Views SharePoint


List Views

Set of six predefined formats:

  1. Standard View This is the classic view style. You can choose fields, sorting and filtering
    rules, grouping, paging, and so on. The result will be a webpage.
  2. Calendar View This view shows data in a calendar format (daily, weekly, or monthly).
  3. Access View This view launches Microsoft Access so users can create forms and reports based on the list’s data.
  4. Datasheet View This view renders data in an editable spreadsheet format (such as Excel),
  5. Gantt View :  renders data in a Gantt chart.
  6. Custom View In SharePoint Designer

Visual Studio Projects for SharePoint


Project Types:

These models simply prepare a pre-configured environment

Item Templates:

1 Oct 2011

SharePoint Version Comparison vs


SharePoint Foundation

  • It is free.
  • Accessibility, cross-browser support, basic search features, out-of-thebox
    Web Parts, Silverlight support, new UI features based on dialogs and ribbons, blogs and
    wikis, and the workflow engine
  • Basic infrastructure of Business Connectivity
  • SharePoint Health Analyzer
  • Custom development, including the Web Parts programming model, the Server Object Model, the Client Object Model, Event Receivers, Claims-Based security


SharePoint Server Standard

  • Useful for building business-level solutions
  • This edition provides legal compliance capabilities, including records management, legal holds, and
    document policies, Document sets, Document IDs
  • Content Management System solution that provides features, such as content publishing, content approval, page layouts, web standards (XHTML, WCAG 2.0, etc.) support,
  • Supports tags and metadata-driven search refinement, people search, and some other social features
  • Managing people, profiles, and personal sites


SharePoint Server Enterprise

  • Targets large business solutions and enterprise-level organizations.
  • Support for dashboards, key performance indicators (KPIs), and business intelligence features.
  • Improves search capabilities by offering contextual search, deep search query refinement, extreme scale-out search capabilities, rich web indexing,
  • Support for Excel Services, Visio Services, InfoPath Forms Services, and Access Services


SharePoint for Internet Sites

Targets web publishing sites, whether the users are anonymous or authenticated

Two Internet site editions:

  • Standard Edition for Internet Sites
  • Enterprise Edition for Internet Sites

Standard Edition for Internet Sites is licensed for publishing a single domain website

Enterprise Edition for Internet Sites can publish multiple domains


SharePoint Online

Microsoft SharePoint Online is the cloud-based SharePoint offering, based on the Software
as a Service (SaaS) paradigm included in Microsoft Office 365


View Version Comparison at:

SharePoint Architecture


architecture of Microsoft SharePoint 2010

Software and hardware requirements of SharePoint 2010:

SharePoint farm

SharePoint farm is a set of servers that have different roles and offer various services that together make up a server farm suitable for hosting a full SharePoint deployment.

Server roles:

Front-end web servers
These servers publish websites, often called web applications.

Application servers
These servers host back-end services, such as the search index service, the crawler service, and so forth.

Database servers
These servers store configuration and content data for the entire SharePoint farm.


Deployment Topology

Single tier deployment
One server performing all roles.

Two-tier deployment
For the sake of scalability and business continuity, you should deploy a minimum
of two front-end web servers and a back-end database server.

Three-tier farm deployment
It has dedicated application servers.


SQL Server Databases:

SharePoint_ Config_<UniqueId> : Main and fundamental farm configuration database

Content Database:  A Content Database is a database file that stores content for one or more Site Collections.

sample SharePoint farm with a three-tier topology
Sample SharePoint farm with a three-tier topology

Business Connectivity Services SharePoint

The Business Connectivity Services is a fundamental application service of Microsoft SharePoint 2010. It provides capabilities to read and write data from external systems, such as Line of Business applications (LOB), web services, databases, or any other external source that offers a suitable connector

architectural schema of the Business Connectivity Services in SharePoint 2010.

Architectural schema of the Business Connectivity Services in SharePoint 2010.

“Creating Custom Business Connectivity Services Connectors Using SharePoint Server 2010”

BDC Server Runtime will store configurations and shapes of data sources in a dedicated repository, which is called BDC Metadata Store and corresponds to a dedicated database file

The BDC Client Runtime, which is a client-side engine that can be automatically installed by SharePoint on any PC client hosting Office 2010


SharePoint Designer 2010 is the ideal solution for modeling SQL Server–based solutions and web/WCF service–based solutions.

Visual Studio 2010 works very well with custom .NET assemblies and custom connectors.


SharePoint Designer 2010 for a new ECT

ECT : External Content Type

Step 1:


Microsoft SharePoint Designer 2010, shown with External Content Types highlighted.



Step 3:

Click the Click Here To Discover External Data Sources And Define Operations link adjacent to External System

Step 4:

Click on Add connection, and provide connection details

SharePoint Designer 2010 gives you the following three options:
.NET Type
SQL Server
WCF Service

Operations Designer window for an ECT.
Operations Designer window for an ECT.


Using the SharePoint Designer 2010 interface, you can define the following operations:
Read Item Corresponds to the method for reading a single row/item.
Read List Corresponds to the method for reading a list of rows/items.
Create Creates a new row/item.
Update Updates an already existing row/item.
Delete Deletes an already existing row/item.

New Association command with which you can create a relationship between two ECTs in a master/detail fashion.



SharePoint Central Administration page for managing Business Data Connectivity Services

SharePoint Central Administration page for managing Business Data Connectivity Services


You can create the external list from SharePoint Designer 2010 or from the web browser.

Choose an External List template and create it.

In the standard properties select the  target ECT, and you are done

User experience is exactly the same of browsing a native list of SharePoint.


You can export the ECT model by using SharePoint Designer 2010 or via the management page of the Business Data Connectivity Services service application.
If you try to export the Customer ECT definition, an XML file with extension .bdcm
(Business Data Connectivity Model)

Capabilities of SharePoint 2010


  1. Sites

    1. Ribbon UI
      SharePoint Workspace
      SharePoint Mobile
      Office Client and Office Web App Integration
      Standards Support

  2. Communities

    1. Tagging, Tag Cloud, Ratings
      Social Bookmarking
      Blogs and Wikis
      My Sites
      Activity Feeds
      Profiles and Expertise
      Org Browser

  3. Content

    1. Enterprise Content Types
      Metadata and Navigation
      Document Sets
      Multi-stage Disposition
      Audio and Video Content Types
      Remote Blob Storage
      List Enhancements

  4. Search

    1. Social Relevance
      Phonetic Search
      FAST Integration
      Enhanced Pipeline

  5. Insights

    1. PerformancePoint Services
      Excel Services
      Chart Web Part
      Visio Services
      Web Analytics
      SQL Server Integration

  6. Composites

    1. Business Connectivity Services
      InfoPath Form Services
      External Lists
      SharePoint Designer
      Visual Studio
      API Enhancements


Web Applications:



Collaboration includes the following templates: Team Site, Blank Site, Document Workspace, Blog, Group Work Site, and Visio Process Repository.


Templates are: Basic Meeting Workspace, Blank Meeting Workspace, Decision Meeting Workspace, Social Meeting Workspace, and Multipage Meeting Workspace.


These templates target enterprise-level needs in the areas of document management, policies, and so on. They include Document Center, Records Center, PowerPoint Broadcast Site, Business Intelligence Center, Enterprise Search Center, My Site Host, Basic Search Center, and FAST Search Center.


Templates are Publishing Portal and Enterprise Wiki.


This is where you can develop your own site templates. Also in this group is a list of all the available custom templates, if any exist.

Use Search engine by Code SharePoint


Federated Search Object Model:  Can query multiple locations and merge all the results together.

Query Object Model: Query the index of SharePoint and FAST Search Server.

Search Engine Assemblies:

Federated Search Object Model

Important class:

QueryManager class

public sealed class QueryManager : List<LocationList> {
public QueryManager();
public string DefaultFASTSearchSort { get; set; }
public int Timeout { get; set; }
public bool TrimDuplicates { get; set; }
public string UserQuery { get; set; }
public XmlDocument GetResults(LocationList locationList);
public bool IsTriggered(LocationList locationList);
public void SendRequest(LocationList locationList, int count);

SearchServiceApplicationProxy class offers a lot of methods for managing federated locations by code

Query Object Model

Query Object Model allows querying only the SharePoint index

Kinds of search queries supported by SharePoint  are:

Keyword Query

SearchServiceApplicationProxy searchServiceProxy =
KeywordQuery keywordQuery = new KeywordQuery(searchServiceProxy);
// Define the query type
keywordQuery.ResultTypes = ResultType.RelevantResults;
keywordQuery.QueryText = searchTerms;
// Execute the query
ResultTableCollection result = keywordQuery.Execute();



Full Text SQL Query

SearchServiceApplicationProxy searchServiceProxy =
FullTextSqlQuery sqlQuery = new FullTextSqlQuery(searchServiceProxy);
// Define the query type
sqlQuery.ResultTypes = ResultType.RelevantResults;
sqlQuery.QueryText = String.Format(
"SELECT Title, Path FROM Scope() WHERE FREETEXT(‘{0}’)", searchTerms);
// Execute the query
ResultTableCollection result = sqlQuery.Execute();



Query Web Service

This is an ASMX service, which is available only in SharePoint Server 2010, and not in SharePoint Foundation 2010.

relative URL /_vti_bin/search.asmx

Search.asmx service is that internally it works with the Query Object Mode

Query queries the index and returns a generic structured XML response.

QueryEx queries the index and returns a DataSet of ADO.NET, serialized as XML.

QueryText element accepts a type attribute, which can assume a value of:
STRING To execute a keyword query.
MSSQLFT To execute a Full Text SQL query.
FQL ( FAST Query Language)

30 Sep 2011

Extend Search Engine SharePoint


Search engine can index the following content sources:

  • Microsoft SharePoint sites
  • File shares
  • Internet websites
  • Microsoft Exchange public folders
  • External databases
  • External Line of Business (LOB) systems

architecture of SharePoint 2010 search engine.
Architecture of SharePoint 2010 search engine.

the external locations can provide search capabilities through various protocols, including the
OpenSearch 1.0/1.1 protocol (http://www.opensearch.org/). The main search engines on the
Internet implement the OpenSearch protocol.


Developer is allowed to extend the search engine mainly in the following areas:

  • Search UI
  • OpenSearch
  • Query Object Model and Federated Search Object Model
  • Query Web Service ( search.asmx)
  • Ranking
  • Custom Content Sources :  You can develop custom connectors, protocol handlers,
    content filters, and security trimmers.


Developing Custom Web Parts

A custom Web Part inherited from the Search Core Results Web Part

public class CustomCoreResultsWebPart : CoreResultsWebPart {
protected override void ModifyXsltArgumentList(
Microsoft.SharePoint.WebPartPages.ArgumentClassWrapper argList) {
// Invoke the base implementation
// Add a parameter with the current user name
String currentUserName = SPContext.Current.Web.CurrentUser.Name;
argList.AddParameter("CurrentUserName", String.Empty, currentUserName);

Base class : CoreResultsWebPart

Methods to override:





It is important to know that all of the Web Parts that render the search pages are coordinated by a unique SharedQueryManager object.

Federation Framework

Adds to SharePoint the capability to define multiple search locations on which to search.

Can use one of the following target providers:

  • Search Index on this Server

  • FAST Index

  • OpenSearch 1.0/1.1

Manage Federated Locations page.


You can define a new location either by filling out a definition form or importing a definition file with the extension .osdx (Open Search Definition XML).

Federation location query is executed in realtime

You can export all the federated locations as .osdx files

By default, a Federated Results Web Part works asynchronously to avoid making the user wait during query results retrieval, but you also have the option to switch to a synchronous query pattern.

Advanced Workflows SharePoint


A dependency property is a property that makes use of a shared repository for the workflow’s state

Namespace: System.Workflow.ComponentModel

Dependency Properties

A dependency property is a property that makes use of a shared repository for the workflow’s state

Dependency properties can be defined in three ways:

  1. Standard Property
  2. Metadata Property
  3. Attached Property

Custom Actions for SharePoint Designer 2010

You can write custom workflow activities  in Visual Studio of your own, making them available as custom actions in SharePoint Designer 2010,


BaseClass: Activity

Important Method to override : Execute
protected override ActivityExecutionStatus Execute( ActivityExecutionContext executionContext) { }

XML manifest file: .ACTIONS extension.


Custom Conditions for SharePoint Designer 2010

A custom condition is just a logical condition that allows the workflow to perform a specific action only if the condition evaluates to true.

user interface of SharePoint Designer 2010 rendering the sample custom condition.

Workflow Event Receivers

A workflow event receiver is a custom class that inherits from the SPWorkflowEventReceiver.

WorkflowStarting Occurs after a workflow instance is starting.
WorkflowStarted Occurs after a workflow instance has been started.
WorkflowPostponed Occurs after a workflow instance has been postponed.
WorkflowCompleted Occurs after a workflow instance is completed.

Workflow Services

It would be better to have an infrastructural service that decouples the communication between the workflow and the CRM. In addition, the time delay spent waiting for the offer code from the external CRM shouldn’t burden the workflow engine.

The external data exchange infrastructure makes use of the CallExternalMethod and HandleExternalEvent activities

The offers approval workflow, extended with the CRM integration.


Base Class: SPWorkflowExternalDataExchangeService
Base abstract class WorkflowSubscriptionService

public override void CallEventHandler(Type eventType, string eventName, object[] eventData, SPWorkflow workflow, string identity, System.Workflow.Runtime.IPendingWork workHandler, object workItem) {}


Workflow Service Deployment

The deployment of a workflow service requires you to build a strongly-named assembly in
order to install the assembly file into the GAC. Next, you need to configure the workflow service
in the web.config of the web application

<WorkflowService Assembly="Dev.SP2010.ExternalCRMService, Version=,
Culture=neutral, PublicKeyToken=665aa2h4h32k420cb" Class="Dev.SP2010.


NOTE:  You can define a feature receiver with a WebApplication scope to automatically configure the web.config file
The SharePoint Server Object Model provides a class named SPWebConfigModification specifically for the purpose configuring the contents of the web.config file automatically.

Full Trust Proxies SharePoint

The architecture of sandboxed solutions provides the capability to utilize external full-trust proxies, deployed and authorized by farm administrators so that you can provide full-trust code execution capabilities to sandboxed solutions.

Full-trust proxies can be installed by farm administrators only,

Implementing a Full-Trust Proxy

Namespace: Microsoft.SharePoint.UserCode
Base Class: SPProxyOperation base abstract class

public class RetrieveNWindCustomers : SPProxyOperation {
public override object Execute(SPProxyOperationArgs args) {
// Operation that require more security rights compar to a SandBox Solution


After implementing the proxy, you need to define a feature with a feature receiver that will
use some custom code for registering it in the farm


Consuming the Full-Trust Proxy

Example: A Web Part that employs the full-trust proxy

   1:  public class ShowNWindCustomers : WebPart {
   2:  protected override void CreateChildControls() {
   3:  RetrieveNWindCustomersArgs args =
   4:  new RetrieveNWindCustomersArgs() {
   5:  SqlConnectionString = this.SqlConnectionString,
   6:  };
   7:  // Invoke the proxy operation
   8:  DataSet data = SPUtility.ExecuteRegisteredProxyOperation(
   9:  typeof(MYPROXYCLASSNAME).Assembly.FullName,
  10:  typeof(RetrieveNWindCustomers).FullName,
  11:  args) as DataSet;
  12:  // ....................
  13:  }
  14:  }

Assembly and Solution Validator SharePoint


Namespace: Microsoft.SharePoint.UserCode

Base Class: SPSolutionValidator,


public virtual void ValidateAssembly(SPSolutionValidationProperties properties,
SPSolutionFile assembly);
public virtual void ValidateSolution(SPSolutionValidationProperties properties);


ValidateAssembly : Validates a single assembly

ValidateSolution: Validate entire solution

To deploy a solution validator you need to select a farmlevel solution and add a farm-level feature.

A solution validator must be registered in the environment, and for this purpose, you can use
a Windows PowerShell script or a custom feature with a feature receiver, both registering the
solution validator by using the SharePoint Server Object Model.

28 Sep 2011

Removing the seconds from DateTime


date = date.AddSeconds( - date.Second));


DateTime date = DateTime.Now;
Console.WriteLine("Date without seconds = {0}", date.AddSeconds(- date.Second));

25 Sep 2011

Claims-Based Authentication SharePoint


architecture of a system with externalized authentication

The externalized authentication provider is generally defined as the Identity Provider (IP) and often publishes a Security Token Service (STS).

The application or software solution externalizing the authentication process is called Service Provider (SP) or Relying Party (RP).

The consumer, who uses the SP authenticating with the IP is generally called the Subject

Web Services Federation Language 1.1 (WS-Federation):  “defines mechanisms to
allow different security realms to federate, such that authorized access to resources managed
in one realm can be provided to security principals whose identities are managed in other

Active Requestor:
Active Scenario (SOAP-oriented) is used by SharePoint 2010 in the service applications’ communication infrastructure.

Passive Requestor:
Web browser based scenario, SharePoint and web/HTTP


sequence diagram of WS-Federation for the Passive Requestor scenario.

Sequence diagram of WS-Federation for the Passive Requestor scenario.

Authorization SharePoint

Authorization in SharePoint is based on Permissions Levels,

Permission Levels can be assigned to users (SPUser) or groups (SPGroup).

A Permission Level is made of a set of permissions,

SharePoint 2010 defines a default set of Permission Levels:

  • View Only View pages, list items, and documents. Document types with server-side
    file handlers can be viewed in the browser but not downloaded.
  • Limited Access View specific lists, document libraries, list items, folders, or documents
    when given permissions.
  • Read View pages and list items, and download documents.
  • Contribute View, add, update, and delete list items and documents.
  • Design View, add, update, delete, approve, and customize.
  • Full Control

24 Sep 2011

Authentication and Authorization SharePoint


Supported authentication methods:

Windows Authentication
Providing support for NTML, Kerberos, Anonymous, Basic, and Digest authentication

Forms-Based Authentication (FBA)
There are providers for LDAP and SQL Server; however, you can develop custom providers of your own. FBA is based on the standard forms authentication provided by Microsoft ASP.NET

SAML token-based Authentication
Uses an external identity provider that supports SAML 1.1 and WS-Federation Passive profile, includes Active Directory Federation Services v. 2.0 (AD FS 2.0), LDAP, or custom third-party identity

About Authentication Types

NTLM-integrated authentication is easier to configure— but it is more limited in capabilities

NTLM is based on the user’s password hash and the front-end server does not have the user’s

Kerberos-integrated authentication utilizes a ticketing infrastructure that is not
based on the user’s password.
Get tickets from a Key Distribution Center (KDC).

Authentication mode:


Classic mode

Supports only the Windows Authentication

Single-server deployment : local users’ repository of the server

Farm deployment: Active Directory repository,

Supported Windows Authentication methods: NTLM, Kerberos, Anonymous, Basic, and Digest


Claims-based mode

Supports all the three available authentication methods

Introduced with SharePoint 2010

With the new claims-based mode you can enable multiple authentication methods within the same zone

The Sign In page, in which end users select the authentication method when multiple authentication

It employs the concept of claims identity, representing each user’s identity as tokens made of claims

Claims are issued by a Claim Provider and packaged into a Security Token, which is emitted by a Security Token Service, also known as an Identity Provider

Claim :

    • ClaimType URI that uniquely defines the type of the claim
    • ClaimValue real content
    • ClaimValueType data type of the ClaimValue



Authentication engine of SharePoint normalizes all the users’ identities into SPUser instances, converting every identity into a set of claims

functional schema of the identity normalization process managed by SharePoint 2010


Windows Authentication

Under claims-based authentication mode, the Windows identities will be converted to a set of claims representing the current user.

User ID of the current user. For Windows Authentication, it assumes a value of “0#.w|[Username]”, where the string “0#.w|” is a trailer and [Username] is the user name of the user. The “w” stands for Windows Authentication.

Extracting claims from a current user’s identity.

ClaimsIdentity ci = this.Page.User.Identity as ClaimsIdentity;
if (ci != null) {
this.Controls.Add(new LiteralControl("<h2>Claims</h2>"));
foreach (Claim c in ci.Claims) {
this.Controls.Add(new LiteralControl(
"<div>ClaimType: {0} - ClaimValue: {1} - ClaimValueType: {2}</div>",
c.ClaimType, c.Value, c.ValueType)));


Forms-Based Authentication

Capability to authenticate your users against an external repository of users, which by default can be an LDAP or a Microsoft SQL Server

By default using the standard SQL Membership Provider of ASP.NET
You can also develop custom membership providers

UserID: “0#.f|[MembershipProvider]|[Username]”, where the string “0#.f|” is a trailer, [MembershipProvider] is the name of the configured Membership Provider, and [Username] is the
username of the user. The “f” stands for FBA.

Configuring the SQL Server Database:

You can invoke ASPNET_REGSQL.EXE within the Visual Studio Command Prompt and have it create a SQL Server database file

Web.config of the sample site for configuring FBA

<add name="FBASP2010" connectionString="server=SP2010DEV\SQLEXPRESS;database=FBA_
ClaimsSP2010;integrated security=SSPI;"/>
<membership defaultProvider="FBASQLMembershipProvider">
<add connectionStringName="FBASP2010" applicationName="/"
passwordAttemptWindow="5" enablePasswordRetrieval="false"
enablePasswordReset="false" requiresQuestionAndAnswer="true"
requiresUniqueEmail="true" passwordFormat="Hashed"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

<roleManager enabled="true" defaultProvider="FBASQLRoleManager">
<add connectionStringName="FBASP2010" applicationName="/"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<authentication mode="Forms" />
<deny users="?"/>
<!-- Configuration omitted for the sake of brevity -->


Configuring SharePoint web.config Files

Web.config located in the C:\inetpub\wwwroot\wss\VirtualDirectories folder of every front-end server


<add name="FBASP2010" connectionString="server=SP2010DEV;database=FBA_
ClaimsSP2010;integrated security=SSPI;"/>


<membership defaultProvider="i">
<add name="i" type="Microsoft.SharePoint.Administration.Claims.
SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" />
<add connectionStringName="FBASP2010" applicationName="/"
passwordAttemptWindow="5" enablePasswordRetrieval="false"
enablePasswordReset="false" requiresQuestionAndAnswer="true"
requiresUniqueEmail="true" passwordFormat="Hashed"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<roleManager defaultProvider="c" enabled="true" cacheRolesInCookie="false">
<add name="c" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider,
Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<add connectionStringName="FBASP2010" applicationName="/"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />


Following web.config needs to be configured:

  1. web.config of the target web application
    Location: C:\inetpub\wwwroot\wss\VirtualDirectories

  2. web.config of the SharePoint Central Administration web application 
    Location: C:\inetpub\wwwroot\wss\VirtualDirectories

  3. web.config of the internal Security Token Service (STS) of SharePoint
    Location: SharePoint14_Root\WebServices\SecurityToken folder.

Configuring SQL Server Permissions

Enable the Windows identities configured for:

  1. SharePoint Central Administration Application Pool

  2. Security Token Service Application Pool

  3. Target Web Application Application Pool

Set for following database role memberships:

  1. aspnet_Membership_FullAccess

  2. aspnet_Roles_FullAccess

Configure the FBA providers through the SharePoint Central Administration interface

Application Management-> Manage Web Applications –> choose the FBA target—>
on the Ribbon click the Authentication Providers command

Edit Authentication configuration page of the SharePoint Central Administration.
Edit Authentication configuration page of the SharePoint Central Administration.

Enabling FBA Users or Roles

Notice that if you now try to browse for users or roles, you will be able to browse both
Windows and FBA users within the same browsing windows

Select People And Groups dialog with multiple authentication providers configured.

21 Sep 2011

Workflow Forms SharePoint


A. Custom .ASPX forms

You can use the same workflow solution with both Microsoft SharePoint Foundation 2010
and Microsoft SharePoint Server 2010

B. Microsoft InfoPath 2010

It don’t support SharePoint Foundation 2010



Association Form

Association form provides the default configuration parameters for automatic startup

Initiation Form

The initiation form targets end users and is presented to them when they manually start a workflow instance.

Modification form

Modification form is useful when you need to change the configuration of a workflow
instance that is already running

Sequential workflow with custom approval


It will be presented to the administrative users while associating the workflow with its target list or Content Type.

C# code behind the out-of-the-box association form page

   1:  public partial class OffersApprovalAssociationForm : LayoutsPageBase {
   2:  // Private fields declaration omitted for the sake of simplicity
   3:  protected void Page_Load(object sender, EventArgs e) {
   4:  InitializeParams();
   5:  }
   6:  private void PopulateFormFields(SPWorkflowAssociation existingAssociation) {
   7:  // Optionally, add code here to pre-populate your form fields.
   8:  }
   9:  // This method is called when the user clicks
  10:  // the button to associate the workflow.
  11:  private string GetAssociationData() {
  12:  // TODO: Return a string that contains the association data that
  13:  // will be passed to the workflow. Typically, this is in XML format.
  14:  return string.Empty;
  15:  }
  16:  protected void AssociateWorkflow_Click(object sender, EventArgs e) {
  17:  // Optionally, add code here to perform additional steps
  18:  // before associating your workflow
  19:  try {
  20:  CreateTaskList();
  21:  CreateHistoryList();
  22:  HandleAssociateWorkflow();
  23:  SPUtility.Redirect("WrkSetng.aspx", SPRedirectFlags.RelativeToLayoutsPage,
  24:  HttpContext.Current, Page.ClientQueryString);
  25:  }
  26:  catch (Exception ex) {
  27:  SPUtility.TransferToErrorPage(String.Format(
  28:  CultureInfo.CurrentCulture, workflowAssociationFailed, ex.Message));
  29:  }
  30:  }
  31:  protected void Cancel_Click(object sender, EventArgs e) {
  32:  SPUtility.Redirect("WrkSetng.aspx", SPRedirectFlags.RelativeToLayoutsPage,
  33:  HttpContext.Current, Page.ClientQueryString);
  34:  }
  36:  }

Workflow Task Forms

Every time a workflow needs to query its users, it assigns them a task.

Workflow Task provides a standard user interface as well as standard fields,
such as Predecessors, Priority, Status, % Complete, and so on. In a real workflow solution, you
probably need to prompt end users with a custom user interface and with custom fields.

  1. Display Form

  2. Edit Form

Workflow Association SharePoint

Associate Workflow with List

Browse to the Settings page of the target list and select the Workflow Settings menu item, under the Permissions And Management menu group

Associate the workflow with a target list


Workflow Versioning



Remove option
Forcibly remove the workflow association without waiting for any running
instances to conclude, the workflow engine of SharePoint will terminate running instances


No New Instances
It prevent new instances of the workflow,
Just after the completion of all the running instances, you can forcibly remove the association.

Correlation Tokens

The hosting environment determines the right workflow instance to deliver the event to, based on that instance ID and the correlation token

Using a correlation token that correlates all the activities related to a specific task
will help the runtime and the workflow instance to uniquely identity the target task inside the
workflow and the corresponding target activity for the event.


Site Workflows

You need to start them manually. To start such workflows, go to the View All Site Content page and select the Site Workflows command

You can start the workflow, provide initiation parameters (if there is an initiation form page), and monitor the workflow status page and history list.

19 Sep 2011

Workflows Architecture SharePoint


WF-Workflow Foundation Overview

Proposed by Microsoft since .NET Framework 3.0.

WF is the foundation for creating custom workflow-enabled solutions

Current version of Workflow Foundation (also known as WF4) is the one that is shipped together with Microsoft .NET Framework 4.0. It is a completely fresh new engine, which is absolutely not compatible with the previous versions of WF (WF 3.0/WF 3.5, or WF 3.x).

However, SharePoint 2010 still uses the previous version of the workflow engine that is WF 3.x


Workflow Foundation Architecture

WF workflow is a set of elements called activities

Simplified overall architecture of WF 3.x.

The main and native runtime services offered by WF 3.x are

  • Loader
  • Scheduler
  • Persistence
  • Tracking
  • Commit Work Batch
  • Communication

Native Activities Offered by WF in . NET 3

  • CallExternalMethod
  • Code
  • Compensate
  • CompensatableSequence
  • ConditionedActivityGroup
  • Delay
  • EventDriven
  • EventHandlingScope
  • FaultHandler
  • HandleExternalEvent
  • IfElse
  • InvokeWebService
  • InvokeWorkflow
  • Listen
  • Parallel
  • Policy
  • Replicator : Replicator can submit the same approval task to a group of approvers.
  • Sequence
  • Suspend
  • SynchronizationScope
  • Terminate
  • Throw : Throw an exception
  • TransactionScope
  • CompensatableTransactionScope
  • WebServiceInput
  • WebServiceOutput
  • WebServiceFault
  • While
  • ReceiveActivity :  Receives data by using a WCF channel and a specific service
    contract, .net 3.5 feature
  • SendActivity


Workflow Types

  1. Sequential workflow
  2. State machine workflow


Sequential workflow [ SequentialWorkflowActivity]

is a workflow that defines a chronologicallyordered flow. it can only move forward, from the starting activity to the ending activity.

Good choice for those scenarios in which you do need very limited user interaction or no user interaction.

for example : data-intensive activities, machine interaction, conversion processes

State machine workflow [ StateMachineWorkflowActivity]

There are rules for moving between one state and another.
Every time a state machine workflow moves into a specified state, it can execute a custom
sequence of steps before moving to the next state

Example: document approval, multi-step process approval, order processing


imageWorkflow designer of a sample sequential workflow


State machine workflow


Activity lifecycle of an activity instance during workflow execution


Architectural schema of Workflow Foundation 3.x hosted in SharePoint 2010.


Workflow Targets and Association

  1. List or Library
  2. Content Type
  3. Site , Example: scheduled maintenance tasks

Types of workflow associations supported by SharePoint 2010

Each workflow definition comprises an XML definition file, the workflow itself, the assemblies
required for the correct workflow execution, and any UI form.

18 Sep 2011

Developing Service Applications


Service Application Architecture

Service application is new version of the Shared Services Provider (SSP) infrastructure of SharePoint 2007.

A service application is a middle-tier service that can be shared between multiple web application instances of the same farm or even across multiple farms.

All the native services of SharePoint 2010 are implemented as service applications


Architectural schema of SharePoint 2010, based on various native service applications


Architecture of a single service application


A service application shared across multiple farms.

By default, SharePoint 2010 installs and preconfigures a couple of service applications

  • Application Discovery and Load Balancer Service Application
  • Security Token Service Application


To manage the service applications environment, you can use the SharePoint Central

Service Application Framework

This is a framework of classes from which you can inherit to build your custom service applications

Creating a Service Application

The main and fundamental components of a service application are

Service engine

Service database

A set of custom rights

Administrative pages

Management scripts for the Windows PowerShell management console.

A proxy library for consuming the service application.

Consumer page, Web Part, or component to use in sites

Custom Protocol Service Application

Business logic to Integrate SharePoint 2010 with an external protocol engine


imageThe custom service applications’ management page, available in SharePoint Central Administration.


You will learn how to define such a page for your developed service:

Upon clicking the OK button, you will see the Protocol Service Application in the list of configured services. However, to use the service you will need to start it on a server of the farm.


After you activate a service instance on a specific server, the Application Discovery And Load Balancer Service Application will begin announcing the availability of that service instance through that specific server, and you will be ready to consume it.


To develop the service application, you need to define a new solution in Visual Studio 2010.
You should create at least four projects

  1. Service application
    This project defines the service, the service application, and all the management pages and scriptlets. It is based on an “Empty SharePoint Project.”
  2. Service contracts
    If you decide to implement the service application as a WCF service, you will need to isolate the communication contracts to share them between the service application and the service application proxy. This project is based on a “Class Library” project targeting .NET Framework 3.5 for x64 or anyCPU platforms.
  3. Service application proxy
    This project implements the code to invoke the service via the base service application proxy. It is based on an “Empty SharePoint Project.”
  4. Service consumer
    This project will host the consumer’s controls, such as Web
    Parts, Web Part Pages, and so on. It is based on an “Empty SharePoint Project.”

17 Sep 2011

Site Definitions versus Web Templates SharePoint


  1. Web template requires only the proper rights to upload the .WSP, Web Template is a sandboxed solution
    A site definition requires physical access to the file system of the servers in the farm.
  2. A web template can be deployed and used in the cloud
    A site definition cannot be deployed in a cloud environment (SharePoint Online or Office 365),
  3. A web template can be versioned without affecting existing site instances
  4. Changes in the pages defined in a web template, will be available only in new sites,
    Changing the layout of pages provisioned through a site definition will also affect previously deployed sites
  5. A web template can do almost everything you can do with a site definition.

Site Templates Development SharePoint

SharePoint 2010 provides many ways for defining site models.

You could have a site definition, which is a site model defined on the file system and stored under the folder SharePoint14_Root\TEMPLATE\SiteTemplates of every front-end server.

You could create a web template either using Microsoft Visual Studio 2010
Saving an already existing site instance through a specific page available in the Site Settings page (under the menu item Save Site As Template in the Site Actions menu group).

A web template can also be exported from SharePoint Designer 2010 as a .WSP package.


Native Site Definitions

Native site definitions are stored in the file system of the servers, in the SharePoint14_Root\TEMPLATES\SiteTemplates


The standard dialog for choosing the template for a new subsiteimage


SharePoint load model from the file name like WEBTEMP*.XML in the SharePoint14_Root\TEMPLATE\{IdCulture}\XML folder,


<?xml version="1.0" encoding="utf-8"?>
<!-- _lcid="1033" _version="14.0.4762" _dal="1" -->
<!-- _LocalBinding -->
<Templates xmlns:ows="Microsoft SharePoint">
<Template Name="GLOBAL" SetupPath="global" ID="0">
<Configuration ID="0" Title="Global template" Hidden="TRUE" ImageUrl=""
Description="This template is used for initializing a new site." ></Configuration>


The WEBTEMP*.XML files are just directories of site templates’ configurations. The actual configuration is included in an XML file, named ONET.XML, which is located in the XML subfolder
of every site definition

The ONET.XML file for the standard STS site template defining STS#0.

<Configuration ID="0" Name="Default" MasterUrl="_catalogs/masterpage/v4.master">
<List FeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101" Type="101"
QuickLaunchUrl="$Resources:core,shareddocuments_Folder;/Forms/AllItems.aspx" />
<List FeatureId="00BFEA71-6A49-43FA-B535-D15C05500108" Type="108"
Folder;/AllItems.aspx" EmailAlias="$Resources:core,discussions_EmailAlias;" />
<!-- Code omitted for the sake of brevity -->
<Module Name="Default" />
<!-- BasicWebParts Feature -->
<Feature ID="00BFEA71-1C5E-4A24-B310-BA51C3EB7A57" />
<!-- Three-state Workflow Feature -->
<Feature ID="FDE5D850-671E-4143-950A-87B473922DC7" />
<!-- TeamCollab Feature -->
<Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" />
<!-- MobilityRedirect -->
<Feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4" />
<!-- WikiPageHomePage Feature -->
<Feature ID="00BFEA71-D8FE-4FEC-8DAD-01C19A6E4053" />

Site Definitions

Steps to manually create a custom site definition:

  1. You could simply copy an existing site definition folder  from SharePoint14_Root\TEMPLATES\SiteTemplates
  2. Change the ONET.XML file to select the lists definition to use for creating list instances, the modules to provision, and the features to activate
  3. Define a custom WEBTEMP*.XML file and copy it into the proper folder, within SharePoint14_Root\TEMPLATES\{IdCulture}\XML

In custom site templates you should use values equal to or greater than 10000 for the ID attribute, to avoid overriding the IDs of native templates



Site Definitions with Visual Studio


The New Project window of Visual Studio 2010 with the Site Definition project template highlighted.

“How to: Create a Custom Site Definition and Configuration,” available on MSDN Online at http://msdn.microsoft.com/en-us/library/ms454677.aspx

For the site definition, your only choice is a farm solution deployment

The template project outline is made up of the minimal contents for defining a site definition: an ONET.XML file, a WEBTEMP*.XML file, and a default.aspx home page.

Avoid activating the features into the deployment target site, it will be site admin task to use the site template.



Custom Web Templates

The list of available site models is made up of site definitions and web templates

A custom web template is created by exporting the definition of an existing site instance,
with or without its content, and storing the result into the content database as a sandboxed

AdjustHijriDays = "Integer"
AlternateCssUrl = "Text"
AlternateHeader = "Text"
BaseTemplateID = "Integer"
BaseTemplateName = "Text"
BaseConfigurationID = "Integer"
CalendarType = "Integer"
Collation = "Integer"
ContainsDefaultLists = "TRUE" | "FALSE"
CustomizedCssFiles = "Text"
CustomJSUrl = "Text"
Description = "Text"
ExcludeFromOfflineClient = "TRUE" | "FALSE"
Locale = "Integer"
Name = "Text"
ParserEnabled = "TRUE" | "FALSE"
PortalName = "Text"
PortalUrl = "Text"
PresenceEnabled = "TRUE" | "FALSE"
ProductVersion = "Integer"
QuickLaunchEnabled = "TRUE" | "FALSE"
Subweb = "TRUE" | "FALSE"
SyndicationEnabled = "TRUE" | "FALSE"
Time24 = "TRUE" | "FALSE"
TimeZone = "Integer"
Title = "Text"
TreeViewEnabled = "Text"
UIVersionConfigurationEnabled = "TRUE" | "FALSE">

The easiest way to create a WebTemplate feature using Visual Studio is to design the site
in the browser. Then you can save it as a template and export the resulting .WSP package
file, downloading it from the Solution Gallery page of the Site Collection. From there, you
simply need to import the .WSP into Visual Studio, creating a new project of type “Import
SharePoint Solution Package.”

WebTemplate feature has been implemented by Microsoft specifically to satisfy the requirement of deploying web templates through sandboxed solutions.

To customize the web template project, you can manually open the imported ONET.XML file
and change its contents.