SlideShare a Scribd company logo
How Do I Connect to That?
Becky Bertram
SharePoint MVP, Microsoft Certified Trainer
MCSD, MCTS, MSPD, MSITP
www.beckybertram.com
Twitter: @beckybertram
 Display information from external systems in UI, such
as web parts, application pages, etc.
 Allow users to interact with external data in
SharePoint list format
 Crawl back-end data sources so they show up in
search results
 Import external data into user profiles
Some Reasons for Connecting to
External Data
 ADO.NET
 LINQ to SQL
 ADO.NET Entity Model
 SharePoint BCS
Options for Data Connection from
SharePoint
 Use ADO.NET object model to connect to
back-end data sources:
 Connection, Command, Parameter objects
 ExecuteScalar(), DataReader.Read() methods
 DataTable, DataSet, DataAdapter objects
ADO.NET
SqlConnection conn = new SqlConnection()
conn.ConnectionString = “DataSource=SERVER;Initial
Catalog=OrderMgmt;Integrated Security=SSPI”;
SqlCommand command = new SqlCommand(“sp_GetOrders”, conn);
conn.Open();
SqlDataReader reader = command.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
reader.Close();
Sample Code
 A way of using strongly typed classes to query
back-end data sources using a T-SQL-like syntax
 Examples of LINQ:
 LINQ to SQL
 LINQ to XML
 LINQ to SharePoint
What is LINQ?
 Strongly typed classes generated by the
SqlMetal.exe tool
 Visual Studio allows you to add LINQ to SQL
project types to your project
 VS gives you a visual interface that dynamically
generates classes behind the scenes for you
 DataContext class provides entry point for code
What is LINQ to SQL?
CustomersDataContext dc = new
CustomersDataContext(“DataSource=SERVER;Initial
Catalog=OrderMgmt;Integrated Security=SSPI”);
IQueryable<Customer> customers = from Customer c
in dc.Customers
where c.Name == "Hot Dog Heaven"
select c;
Customer customer = customers.First<Customer>();
int customerId = customer.ID;
LINQ to SQL Sample
 An entity is a generic term for something that has properties
and instructions for performing actions
 A database table has columns (properties) and uses SQL
statements or stored procedures to carry out CRUD operations
 An Excel spreadsheet has rows and columns and uses functions
to carry out operations
 An object model has classes with properties and methods to
carry out operations
What is the ADO.NET Entity Model?
SQL Diagram vs Entity Model
The ADO.NET Entity model allows you to create an object model that mirrors
your application logic and not necessarily your data source
 VS 2010 gives you a nice interface for creating Entity Models
 VS gives you two automatic options:
 Create an entity model by hand, then have VS create a SQL
script that will generate a database that mirrors your
entity model
 Connect to a database and have an entity model created
automatically that reflects the DB design
 You also can create an entity model and manually wire
entities up to stored procedures (thus creating a more de-
coupled model)
Entity Models and Visual Studio
 It is possible to use LINQ with an Entity Model,
i.e. the LINQ statements returns Entity Model
objects
 The Entity Model itself isn’t usually tied to
LINQ to SQL
LINQ and Entity Models
 All three of these models require connection strings to connect
to the backend database
 In typical ASP.NET applications, connection strings are stored in
the web.config file so they can be swapped out easily in each
new environment (Dev, QA, Prod, etc.)
 SharePoint WFE can be load balanced, so it’s not recommended
to modify the web.config by hand
 SharePoint object model provides a way of programmatically
modifying the web.config file on multiple WFEs.
Managing Application Configuration
SPConfigModification configMod = new SPWebConfigModification();
configMod.Name = “add”;
configMod.Owner = “sp_serviceAccount”;
configMod.Sequence = 1;
configMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
configMod.Value = “DataSource=SERVER;Initial Catalog=OrderMgmt;Integrated Security=SSPI”;
webApp.WebConfigModifications.Add(configMod);
webApp.WebService.ApplyWebConfigModifications();
SPWebConfigModification
 SPWebConfigModification solution requires writing your connection
string in code; defeats the purpose of using the web.config
 Other storage option: store the connection string in SharePoint itself
 Store in the property bag of a SPWebApplication, SPSite, or SPWeb
object
 Plus: easily accessible via code; can be different for each environment
 Minus: No user interface out of the box; UI for updating those values must be
written
 Store in a SharePoint list
 Plus: UI already built; security, change management, etc. there already
 Minus: Not so good performance; list couple be deleted more easily than
accidentally deleting a property in the property bag, potentially
 SharePoint Patterns and Practices:
 Variation of property bag
 Allows you to set config values higher up in the hierarchy and then query
them within a lower context; no hardcoded to setting values specifically in an
object such as a web application, site collection, etc.
Environment-specific Connection
Strings
 Best practice is to connect to SQL using a trusted
connection (as opposed to using SQL authentication)
 This means users will be connecting to the back-end
database using the SharePoint web application’s
application pool process identity. You must grant that
account the proper permissions in the external
database.
Connection Context
 A means of connecting SharePoint 2010 and Office
applications to external data sources.
 The term BCS refers to the connectivity components, tools,
and user interface components such as web parts, that
combine to make integration with external systems possible.
 Business Data Connectivity (BDC) is refers to just the
connectivity runtime. (Business Data Catalog is the
SharePoint 2007 term for the BCS.)
 Unlike SP2007 that only allowed Read functionality, BCS
allows standard CRUD operations on the external system.
 Can be used to search external data sources
 Can be used as a data source for the User Profile Service
What are Business Connectivity
Services (BCS)?
Authentication Type Kerberos
or NTLM
Description
Passthrough Kerberos Uses credentials of current user
Passthrough NTLM Uses credentials of app pool account or anonymous user account
RevertToSelf Uses credentials of the app pool
WindowsCredentials BCS uses SSS credentials as Windows credentials. Must pass in
Target Application name.
RdbCredentials Passes in username and password to a DB, appended to the
connection string (such as when using SQL Authentication). Must
pass in Target Application name
Credentials Used to access web services that don’t support Windows
authentication, but use Basic or Digest authentication. Must pass
in Target Application name
Application-Level
Authentication
Passes credentials along with parameters when carrying out a
Read operation on external data source.
BCS Authentication Choices
 Provides the ability to map credentials of SharePoint users or
groups to user accounts used for accessing external systems.
 Can specify if each user gets mapped to an individual account,
or if all the users in a given group map to a single account.
 Each SSS entry has an “Application Name”. It’s possible to
create BCS connections that use the credentials stored with a
particular Application Name. This means you could create the
same Application Name in your different environments, but
use different credentials. Your BCS model wouldn’t need to
change.
Secure Store Service
 Also known as an Entity in Visual Studio, to be consistent with the
BCS object model.
 Similar to an object with properties when referring to object
models, or tables with columns when referring to databases.
 ECT could be something like “Customer”, “Product”, etc.
 ECT is like a traditional content type in that it includes a collection
of metadata to describe an item. Storage mechanism for ECT is
totally different than a traditional SharePoint content type.
 ECTs can have Associations, which is the equivalent of foreign
keys.
External Content Types (ECT)
 Contains:
 ECT definitions
 ECT associations
 ECT security permissions
 Created using:
 SPD
 Visual Studio
 3rd Party Tools
 XML Editor
 Programmatically using BCS Administration object model
Metadata Model
<Entities>
<Entity Namespace="http://sandbox.sp2010.com/sites/bdc" Version="1.0.0.0"
EstimatedInstanceCount="10000" Name="Product" DefaultDisplayName="Product">
<Properties>
<Property Name="Title" Type="System.String">Name</Property>
<Property Name="ExcludeFromOfflineClientForList" Type="System.Boolean">true</Property>
</Properties>
<Identifiers>
<Identifier TypeName="System.Int32" Name="ProductID" />
</Identifiers>
<Methods>
<Method IsStatic="false" Name="DeleteProduct">
<Properties>
<Property Name="RdbCommandType" Type="System.Data.CommandType, System.Data,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">StoredProcedure</Property>
<Property Name="RdbCommandText"
Type="System.String">[dbo].[DeleteProduct]</Property>
<Property Name="BackEndObjectType" Type="System.String">SqlServerRoutine</Property>
<Property Name="BackEndObject" Type="System.String">DeleteProduct</Property>
<Property Name="Schema" Type="System.String">dbo</Property>
</Properties>
Sample Entity from BDC Model
<Parameters>
<Parameter Direction="In" Name="@ProductID">
<TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
IdentifierName="ProductID" Name="@ProductID" />
</Parameter>
</Parameters>
<MethodInstances>
<MethodInstance Type="Deleter" Name="DeleteProduct" DefaultDisplayName="Delete
Product">
</MethodInstance>
</MethodInstances>
</Method>
</Entity>
</Entities>
Sample Entity Cont’d
 Resource files can be used to upload unique language
values, security settings, and connection values
 You can export a BCS metadata model to XML, import
that model to a different model, then import an
additional resource file in each new environment.
That resource file could contain server-specific
connection info.
BCS Resource Files
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.microsoft.com/windows/2007/BusinessDataCatalog BDCMetadata.xsd" Name="BCS Product"
xmlns="http://schemas.microsoft.com/windows/2007/BusinessDataCatalog/Resources">
<AccessControlList>
<AccessControlEntry Principal="sp2010administrator">
<Right BdcRight="Edit" />
<Right BdcRight="Execute" />
<Right BdcRight="SetPermissions" />
<Right BdcRight="SelectableInClients" />
</AccessControlEntry>
</AccessControlList>
<LobSystems>
<LobSystem Name="BCS Test">
<LobSystemInstances>
<LobSystemInstance Name="BCS Test">
<Properties>
<Property Name="AuthenticationMode" Type="System.String">WindowsCredentials</Property>
<Property Name="DatabaseAccessProvider" Type="System.String">SqlServer</Property>
<Property Name="RdbConnection Data Source" Type="System.String">WIN-28QOC9KSJHL</Property>
<Property Name="RdbConnection Initial Catalog" Type="System.String">BCSTest</Property>
<Property Name="RdbConnection Integrated Security" Type="System.String">SSPI</Property>
<Property Name="RdbConnection Pooling" Type="System.String">True</Property>
<Property Name="SsoProviderImplementation"
Type="System.String">Microsoft.Office.SecureStoreService.Server.SecureStoreProvider, Microsoft.Office.SecureStoreService,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Property>
<Property Name="SsoApplicationId" Type="System.String">BDC</Property>
<Property Name="ShowInSearchUI" Type="System.String"></Property>
</Properties>
</LobSystemInstance>
</LobSystemInstances>
</LobSystem>
</LobSystems>
</Model>
Sample Resource File
 A SharePoint list that was created using the definition
defined in an ECT.
 Not every ECT needs to have an External List. An EL is simply
an embodiment of the ECT in SharePoint, but it’s not
necessary to have an EL to access an ECT. It’s also possible to
use the BDC object model to access External Data directly,
without having an EL.
 EL forms can either use a standard List View Web Part or they
can be generated using InfoPath.
 Once data is in an EL, programmers can program against list
items using the standard SharePoint object model
External List
 Web Service/WCF Service
 SQL Server
 .NET Connectivity Component
 Custom
Connectors
 You can use SharePoint Designer’s tools to create
your BDC model
 You can auto-generate SQL queries or specify stored
procedures that need to be executed
SQL Connector
 Your BCS model can connect to .NET objects in an assembly, and
those objects can handle doing the CRUD operations
 Visual Studio allows you to create a BCS model using a project
item template
 Your BCS model is tied to .NET classes in VS. You can write
custom code in the methods you define (typically CRUD
methods) that access your ADO.NET entities or your LINQ to
SQL DataContext objects.
 You could create a web service that exposes your entity model
or LINQ to SQL classes and connect your BCS model to it
.NET Connectors
 ADO.NET object model connecting directly to DB
 ADO.NET Data classes that use LINQ to retrieve content
from DB
 ADO.NET Entity Model that’s configured to connect to a
back-end DB
 BCS to SQL
 BCS to Web Service/WCF
 BCS to .NET classes which use an Entity Model you’ve
created to return values
 BCS to .NET classes that use LINQ to SQL to return values
Summary: Connection Options
 ADO.NET, Entity Model, and LINQ to SQL:
 Connects to back-end database using SharePoint Web
Application IIS application pool identity
 Store connection string in web.config using
SPWebConfigModification or within SharePoint itself (using
property bag, with or without the aid of the Patterns and
Practices code library; or in a SharePoint list)
 BCS:
 Store credentials right in the model or store credentials using
the Secure Store Service
 Change configuration in each environment by uploading
Resource files associated with the BCS model
Configuration Options
 ADO.NET Entity Framework on MSDN:
http://msdn.microsoft.com/en-us/library/bb399572.aspx
 Wrox Professional Business Connectivity
Services in SharePoint 2010
 Secure Store Service on MSDN:
http://msdn.microsoft.com/en-us/library/ee557754.aspx
 LINQ to SQL on MSDN:
http://msdn.microsoft.com/en-us/library/bb386976.aspx
 Managing Application Configuration on MSDN:
http://msdn.microsoft.com/en-us/library/ee413935.aspx
 BCS Meta Man by Lightning Tools:
 http://lightningtools.com/bcs/bcs-meta-man.aspx
 SharePoint Property Bag Settings 2010:
http://pbs2010.codeplex.com
Resources

More Related Content

DOCX
CAD Report
PDF
Azure data factory security
PPT
Hibernate
PPTX
Develop iOS and Android apps with SharePoint/Office 365
PDF
Spring Framework-II
PPTX
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
PPTX
Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...
PDF
Spring Framework - III
CAD Report
Azure data factory security
Hibernate
Develop iOS and Android apps with SharePoint/Office 365
Spring Framework-II
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...
Spring Framework - III

What's hot (20)

DOCX
SharePoint solution developer exam 70-488
PPTX
Exam 70-489 Developing Microsoft SharePoint Server 2013 Advanced Solutions Le...
PPTX
Introduction to the SharePoint Client Object Model and REST API
PPTX
SharePoint 2010 Application Development Overview
PPT
Utilized Code Gen To Save Our Efforts In Sap Integration
PPTX
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
PDF
PDF
Services ax2012
PPTX
Building business applications using business connectivity services using sha...
PPTX
Advanced SharePoint Web Part Development
PDF
Hibernate I
DOCX
Wei ding(resume)
PDF
Hibernate III
PPT
Sharepoint Online
PDF
Best practices in using Salesforce Metadata API
PPTX
Integrating SharePoint 2010 and Visual Studio Lightswitch
PPTX
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
DOCX
SSO to Office365 using Active Directory Credentials
DOCX
SAP BO ONLINE TRAINING
PPTX
Advanced BCS - Business Data Connectivity Models and Custom Connectors
SharePoint solution developer exam 70-488
Exam 70-489 Developing Microsoft SharePoint Server 2013 Advanced Solutions Le...
Introduction to the SharePoint Client Object Model and REST API
SharePoint 2010 Application Development Overview
Utilized Code Gen To Save Our Efforts In Sap Integration
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
Services ax2012
Building business applications using business connectivity services using sha...
Advanced SharePoint Web Part Development
Hibernate I
Wei ding(resume)
Hibernate III
Sharepoint Online
Best practices in using Salesforce Metadata API
Integrating SharePoint 2010 and Visual Studio Lightswitch
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
SSO to Office365 using Active Directory Credentials
SAP BO ONLINE TRAINING
Advanced BCS - Business Data Connectivity Models and Custom Connectors
Ad

Viewers also liked (17)

PPTX
Office 365 Connectorsv1
PPTX
SPSMad2016 Rubén Toribio - Template
PPTX
Creating No-Code BCS Solutions in SharePoint 2010 and Office 2010–From TechEd...
PPTX
Surfacing Your External Data using BCS in SharePoint 2013 - Dev Connections 2013
PPTX
Power BI for Developers @ SQLSaturday #420 (Paris)
PPTX
Office 365 Connectors
PPTX
Sql Saturday 228 Rapid Data Integration Using SharePoint BCS
PPTX
Power BI for Developers @ SQLSaturday #369
PPTX
SharePoint 2016 Search
PPTX
PowerApps, the Developer Story: Build an API to Integrate Corporate Data
PPTX
SharePoint BCS, OK. But what is the SharePoint Business Data List Connector (...
PDF
Tuga IT - Power BI for Developers
PPTX
PowerApps, the Developer Story: Build an API to Integrate Corporate Data
PPTX
BI : SharePoint 2016 BI or PowerBI v2 ? (O365 Saturday Copenhagen, 2016)
PPTX
Enterprise Integration Pack & On-Premises Data Gateway
PPT
Introduction to ADO.NET
PPTX
Business Intelligence with PowerBI for SharePoint Online
Office 365 Connectorsv1
SPSMad2016 Rubén Toribio - Template
Creating No-Code BCS Solutions in SharePoint 2010 and Office 2010–From TechEd...
Surfacing Your External Data using BCS in SharePoint 2013 - Dev Connections 2013
Power BI for Developers @ SQLSaturday #420 (Paris)
Office 365 Connectors
Sql Saturday 228 Rapid Data Integration Using SharePoint BCS
Power BI for Developers @ SQLSaturday #369
SharePoint 2016 Search
PowerApps, the Developer Story: Build an API to Integrate Corporate Data
SharePoint BCS, OK. But what is the SharePoint Business Data List Connector (...
Tuga IT - Power BI for Developers
PowerApps, the Developer Story: Build an API to Integrate Corporate Data
BI : SharePoint 2016 BI or PowerBI v2 ? (O365 Saturday Copenhagen, 2016)
Enterprise Integration Pack & On-Premises Data Gateway
Introduction to ADO.NET
Business Intelligence with PowerBI for SharePoint Online
Ad

Similar to How do i connect to that (20)

PPTX
Where to save my data, for devs!
PPTX
Building Solutions With Business Connectivity Services
PPTX
Building Custom BCS .NET Connectors
PPTX
Is BCS Dead?
PPTX
Fabian Williams Business Connectivity Services SharePoint Saturday DC Deck
PPTX
SharePoint 2010
PPTX
SharePoint Fest Chicago - SharePoint 2010 Integration and Interoperability: W...
PPTX
Fabian Williams BCS Session Spsnola
PDF
Architecting solutions connecting to lob applications
PDF
Architecting solutions connecting to lob applications
PPTX
Business Connectivity Services With Share Point 2010
PPTX
Business connectivity solutions runtime and object model deep dive (part 2)
PPTX
Best Practices - SharePoint 2010: Integration and Interoperability
PPTX
Best Practices Integration And Interoperability
PPTX
SharePoint Fest Denver - SharePoint 2010 Integration and Interoperability: Wh...
PPTX
SharePoint Fest Denver - SharePoint 2010 Integration and Interoperability: Wh...
PPTX
SPS South Florida BCS Deck
PPSX
SharePoint 2010 Integration and Interoperability: What you need to know
PPTX
SharePoint 2010 Integration and Interoperability - SharePoint Saturday Hartford
Where to save my data, for devs!
Building Solutions With Business Connectivity Services
Building Custom BCS .NET Connectors
Is BCS Dead?
Fabian Williams Business Connectivity Services SharePoint Saturday DC Deck
SharePoint 2010
SharePoint Fest Chicago - SharePoint 2010 Integration and Interoperability: W...
Fabian Williams BCS Session Spsnola
Architecting solutions connecting to lob applications
Architecting solutions connecting to lob applications
Business Connectivity Services With Share Point 2010
Business connectivity solutions runtime and object model deep dive (part 2)
Best Practices - SharePoint 2010: Integration and Interoperability
Best Practices Integration And Interoperability
SharePoint Fest Denver - SharePoint 2010 Integration and Interoperability: Wh...
SharePoint Fest Denver - SharePoint 2010 Integration and Interoperability: Wh...
SPS South Florida BCS Deck
SharePoint 2010 Integration and Interoperability: What you need to know
SharePoint 2010 Integration and Interoperability - SharePoint Saturday Hartford

More from Becky Bertram (13)

PPTX
Introduction to Communication Sites
PPTX
Microsoft Graph
PPTX
SharePoint 2010 Tools in Visual Studio 2010
PPTX
SharePoint and Open XML
PPTX
SharePoint Publishing 101
PPTX
Help! I've got a share point site! Now What?
PPTX
Developing retention rules that work
PPTX
My First SharePoint Online PowerApp
PPTX
Share point development 101
PPTX
So you’re building an intranet
PPTX
Microsoft Exam 70-331 Exam Cram Study Guide
PPTX
Exam Cram for 70-488: Developing Microsoft SharePoint Server 2013 Core Solutions
PPTX
Social Features of SharePoint 2013: Enhancing Productivity
Introduction to Communication Sites
Microsoft Graph
SharePoint 2010 Tools in Visual Studio 2010
SharePoint and Open XML
SharePoint Publishing 101
Help! I've got a share point site! Now What?
Developing retention rules that work
My First SharePoint Online PowerApp
Share point development 101
So you’re building an intranet
Microsoft Exam 70-331 Exam Cram Study Guide
Exam Cram for 70-488: Developing Microsoft SharePoint Server 2013 Core Solutions
Social Features of SharePoint 2013: Enhancing Productivity

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
A Presentation on Artificial Intelligence
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Modernizing your data center with Dell and AMD
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
KodekX | Application Modernization Development
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Approach and Philosophy of On baking technology
Unlocking AI with Model Context Protocol (MCP)
A Presentation on Artificial Intelligence
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Understanding_Digital_Forensics_Presentation.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Modernizing your data center with Dell and AMD
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
KodekX | Application Modernization Development
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
20250228 LYD VKU AI Blended-Learning.pptx

How do i connect to that

  • 1. How Do I Connect to That? Becky Bertram SharePoint MVP, Microsoft Certified Trainer MCSD, MCTS, MSPD, MSITP www.beckybertram.com Twitter: @beckybertram
  • 2.  Display information from external systems in UI, such as web parts, application pages, etc.  Allow users to interact with external data in SharePoint list format  Crawl back-end data sources so they show up in search results  Import external data into user profiles Some Reasons for Connecting to External Data
  • 3.  ADO.NET  LINQ to SQL  ADO.NET Entity Model  SharePoint BCS Options for Data Connection from SharePoint
  • 4.  Use ADO.NET object model to connect to back-end data sources:  Connection, Command, Parameter objects  ExecuteScalar(), DataReader.Read() methods  DataTable, DataSet, DataAdapter objects ADO.NET
  • 5. SqlConnection conn = new SqlConnection() conn.ConnectionString = “DataSource=SERVER;Initial Catalog=OrderMgmt;Integrated Security=SSPI”; SqlCommand command = new SqlCommand(“sp_GetOrders”, conn); conn.Open(); SqlDataReader reader = command.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(reader); reader.Close(); Sample Code
  • 6.  A way of using strongly typed classes to query back-end data sources using a T-SQL-like syntax  Examples of LINQ:  LINQ to SQL  LINQ to XML  LINQ to SharePoint What is LINQ?
  • 7.  Strongly typed classes generated by the SqlMetal.exe tool  Visual Studio allows you to add LINQ to SQL project types to your project  VS gives you a visual interface that dynamically generates classes behind the scenes for you  DataContext class provides entry point for code What is LINQ to SQL?
  • 8. CustomersDataContext dc = new CustomersDataContext(“DataSource=SERVER;Initial Catalog=OrderMgmt;Integrated Security=SSPI”); IQueryable<Customer> customers = from Customer c in dc.Customers where c.Name == "Hot Dog Heaven" select c; Customer customer = customers.First<Customer>(); int customerId = customer.ID; LINQ to SQL Sample
  • 9.  An entity is a generic term for something that has properties and instructions for performing actions  A database table has columns (properties) and uses SQL statements or stored procedures to carry out CRUD operations  An Excel spreadsheet has rows and columns and uses functions to carry out operations  An object model has classes with properties and methods to carry out operations What is the ADO.NET Entity Model?
  • 10. SQL Diagram vs Entity Model The ADO.NET Entity model allows you to create an object model that mirrors your application logic and not necessarily your data source
  • 11.  VS 2010 gives you a nice interface for creating Entity Models  VS gives you two automatic options:  Create an entity model by hand, then have VS create a SQL script that will generate a database that mirrors your entity model  Connect to a database and have an entity model created automatically that reflects the DB design  You also can create an entity model and manually wire entities up to stored procedures (thus creating a more de- coupled model) Entity Models and Visual Studio
  • 12.  It is possible to use LINQ with an Entity Model, i.e. the LINQ statements returns Entity Model objects  The Entity Model itself isn’t usually tied to LINQ to SQL LINQ and Entity Models
  • 13.  All three of these models require connection strings to connect to the backend database  In typical ASP.NET applications, connection strings are stored in the web.config file so they can be swapped out easily in each new environment (Dev, QA, Prod, etc.)  SharePoint WFE can be load balanced, so it’s not recommended to modify the web.config by hand  SharePoint object model provides a way of programmatically modifying the web.config file on multiple WFEs. Managing Application Configuration
  • 14. SPConfigModification configMod = new SPWebConfigModification(); configMod.Name = “add”; configMod.Owner = “sp_serviceAccount”; configMod.Sequence = 1; configMod.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode; configMod.Value = “DataSource=SERVER;Initial Catalog=OrderMgmt;Integrated Security=SSPI”; webApp.WebConfigModifications.Add(configMod); webApp.WebService.ApplyWebConfigModifications(); SPWebConfigModification
  • 15.  SPWebConfigModification solution requires writing your connection string in code; defeats the purpose of using the web.config  Other storage option: store the connection string in SharePoint itself  Store in the property bag of a SPWebApplication, SPSite, or SPWeb object  Plus: easily accessible via code; can be different for each environment  Minus: No user interface out of the box; UI for updating those values must be written  Store in a SharePoint list  Plus: UI already built; security, change management, etc. there already  Minus: Not so good performance; list couple be deleted more easily than accidentally deleting a property in the property bag, potentially  SharePoint Patterns and Practices:  Variation of property bag  Allows you to set config values higher up in the hierarchy and then query them within a lower context; no hardcoded to setting values specifically in an object such as a web application, site collection, etc. Environment-specific Connection Strings
  • 16.  Best practice is to connect to SQL using a trusted connection (as opposed to using SQL authentication)  This means users will be connecting to the back-end database using the SharePoint web application’s application pool process identity. You must grant that account the proper permissions in the external database. Connection Context
  • 17.  A means of connecting SharePoint 2010 and Office applications to external data sources.  The term BCS refers to the connectivity components, tools, and user interface components such as web parts, that combine to make integration with external systems possible.  Business Data Connectivity (BDC) is refers to just the connectivity runtime. (Business Data Catalog is the SharePoint 2007 term for the BCS.)  Unlike SP2007 that only allowed Read functionality, BCS allows standard CRUD operations on the external system.  Can be used to search external data sources  Can be used as a data source for the User Profile Service What are Business Connectivity Services (BCS)?
  • 18. Authentication Type Kerberos or NTLM Description Passthrough Kerberos Uses credentials of current user Passthrough NTLM Uses credentials of app pool account or anonymous user account RevertToSelf Uses credentials of the app pool WindowsCredentials BCS uses SSS credentials as Windows credentials. Must pass in Target Application name. RdbCredentials Passes in username and password to a DB, appended to the connection string (such as when using SQL Authentication). Must pass in Target Application name Credentials Used to access web services that don’t support Windows authentication, but use Basic or Digest authentication. Must pass in Target Application name Application-Level Authentication Passes credentials along with parameters when carrying out a Read operation on external data source. BCS Authentication Choices
  • 19.  Provides the ability to map credentials of SharePoint users or groups to user accounts used for accessing external systems.  Can specify if each user gets mapped to an individual account, or if all the users in a given group map to a single account.  Each SSS entry has an “Application Name”. It’s possible to create BCS connections that use the credentials stored with a particular Application Name. This means you could create the same Application Name in your different environments, but use different credentials. Your BCS model wouldn’t need to change. Secure Store Service
  • 20.  Also known as an Entity in Visual Studio, to be consistent with the BCS object model.  Similar to an object with properties when referring to object models, or tables with columns when referring to databases.  ECT could be something like “Customer”, “Product”, etc.  ECT is like a traditional content type in that it includes a collection of metadata to describe an item. Storage mechanism for ECT is totally different than a traditional SharePoint content type.  ECTs can have Associations, which is the equivalent of foreign keys. External Content Types (ECT)
  • 21.  Contains:  ECT definitions  ECT associations  ECT security permissions  Created using:  SPD  Visual Studio  3rd Party Tools  XML Editor  Programmatically using BCS Administration object model Metadata Model
  • 22. <Entities> <Entity Namespace="http://sandbox.sp2010.com/sites/bdc" Version="1.0.0.0" EstimatedInstanceCount="10000" Name="Product" DefaultDisplayName="Product"> <Properties> <Property Name="Title" Type="System.String">Name</Property> <Property Name="ExcludeFromOfflineClientForList" Type="System.Boolean">true</Property> </Properties> <Identifiers> <Identifier TypeName="System.Int32" Name="ProductID" /> </Identifiers> <Methods> <Method IsStatic="false" Name="DeleteProduct"> <Properties> <Property Name="RdbCommandType" Type="System.Data.CommandType, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">StoredProcedure</Property> <Property Name="RdbCommandText" Type="System.String">[dbo].[DeleteProduct]</Property> <Property Name="BackEndObjectType" Type="System.String">SqlServerRoutine</Property> <Property Name="BackEndObject" Type="System.String">DeleteProduct</Property> <Property Name="Schema" Type="System.String">dbo</Property> </Properties> Sample Entity from BDC Model
  • 23. <Parameters> <Parameter Direction="In" Name="@ProductID"> <TypeDescriptor TypeName="System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" IdentifierName="ProductID" Name="@ProductID" /> </Parameter> </Parameters> <MethodInstances> <MethodInstance Type="Deleter" Name="DeleteProduct" DefaultDisplayName="Delete Product"> </MethodInstance> </MethodInstances> </Method> </Entity> </Entities> Sample Entity Cont’d
  • 24.  Resource files can be used to upload unique language values, security settings, and connection values  You can export a BCS metadata model to XML, import that model to a different model, then import an additional resource file in each new environment. That resource file could contain server-specific connection info. BCS Resource Files
  • 25. <?xml version="1.0" encoding="utf-8" standalone="yes"?> <Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.microsoft.com/windows/2007/BusinessDataCatalog BDCMetadata.xsd" Name="BCS Product" xmlns="http://schemas.microsoft.com/windows/2007/BusinessDataCatalog/Resources"> <AccessControlList> <AccessControlEntry Principal="sp2010administrator"> <Right BdcRight="Edit" /> <Right BdcRight="Execute" /> <Right BdcRight="SetPermissions" /> <Right BdcRight="SelectableInClients" /> </AccessControlEntry> </AccessControlList> <LobSystems> <LobSystem Name="BCS Test"> <LobSystemInstances> <LobSystemInstance Name="BCS Test"> <Properties> <Property Name="AuthenticationMode" Type="System.String">WindowsCredentials</Property> <Property Name="DatabaseAccessProvider" Type="System.String">SqlServer</Property> <Property Name="RdbConnection Data Source" Type="System.String">WIN-28QOC9KSJHL</Property> <Property Name="RdbConnection Initial Catalog" Type="System.String">BCSTest</Property> <Property Name="RdbConnection Integrated Security" Type="System.String">SSPI</Property> <Property Name="RdbConnection Pooling" Type="System.String">True</Property> <Property Name="SsoProviderImplementation" Type="System.String">Microsoft.Office.SecureStoreService.Server.SecureStoreProvider, Microsoft.Office.SecureStoreService, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Property> <Property Name="SsoApplicationId" Type="System.String">BDC</Property> <Property Name="ShowInSearchUI" Type="System.String"></Property> </Properties> </LobSystemInstance> </LobSystemInstances> </LobSystem> </LobSystems> </Model> Sample Resource File
  • 26.  A SharePoint list that was created using the definition defined in an ECT.  Not every ECT needs to have an External List. An EL is simply an embodiment of the ECT in SharePoint, but it’s not necessary to have an EL to access an ECT. It’s also possible to use the BDC object model to access External Data directly, without having an EL.  EL forms can either use a standard List View Web Part or they can be generated using InfoPath.  Once data is in an EL, programmers can program against list items using the standard SharePoint object model External List
  • 27.  Web Service/WCF Service  SQL Server  .NET Connectivity Component  Custom Connectors
  • 28.  You can use SharePoint Designer’s tools to create your BDC model  You can auto-generate SQL queries or specify stored procedures that need to be executed SQL Connector
  • 29.  Your BCS model can connect to .NET objects in an assembly, and those objects can handle doing the CRUD operations  Visual Studio allows you to create a BCS model using a project item template  Your BCS model is tied to .NET classes in VS. You can write custom code in the methods you define (typically CRUD methods) that access your ADO.NET entities or your LINQ to SQL DataContext objects.  You could create a web service that exposes your entity model or LINQ to SQL classes and connect your BCS model to it .NET Connectors
  • 30.  ADO.NET object model connecting directly to DB  ADO.NET Data classes that use LINQ to retrieve content from DB  ADO.NET Entity Model that’s configured to connect to a back-end DB  BCS to SQL  BCS to Web Service/WCF  BCS to .NET classes which use an Entity Model you’ve created to return values  BCS to .NET classes that use LINQ to SQL to return values Summary: Connection Options
  • 31.  ADO.NET, Entity Model, and LINQ to SQL:  Connects to back-end database using SharePoint Web Application IIS application pool identity  Store connection string in web.config using SPWebConfigModification or within SharePoint itself (using property bag, with or without the aid of the Patterns and Practices code library; or in a SharePoint list)  BCS:  Store credentials right in the model or store credentials using the Secure Store Service  Change configuration in each environment by uploading Resource files associated with the BCS model Configuration Options
  • 32.  ADO.NET Entity Framework on MSDN: http://msdn.microsoft.com/en-us/library/bb399572.aspx  Wrox Professional Business Connectivity Services in SharePoint 2010  Secure Store Service on MSDN: http://msdn.microsoft.com/en-us/library/ee557754.aspx  LINQ to SQL on MSDN: http://msdn.microsoft.com/en-us/library/bb386976.aspx  Managing Application Configuration on MSDN: http://msdn.microsoft.com/en-us/library/ee413935.aspx  BCS Meta Man by Lightning Tools:  http://lightningtools.com/bcs/bcs-meta-man.aspx  SharePoint Property Bag Settings 2010: http://pbs2010.codeplex.com Resources