SharePoint 2010 Secure Store Service and MS SQL

In this walkthrough we will show using SharePoint 2010 Secure Store in Business Connectivity Services for integration with MS SQL using Windows Authentication by means of BCS Meta Man (the same way you may use Secure Store and SQL Server Authentication).

The Secure Store Service replaces the single sign-on (SSO) feature in SharePoint 2010. The Secure Store Service is authorization service that contains a secure database for storing credentials (e.g. user name and password) that are associated with application IDs. These application IDs can be used to authorize access to external database. Target Application IDs map users to the credentials that will be passed to the external data source. Mappings are available for groups (e.g. domain group) or individuals (e.g. local or domain users). When connecting to the external data source, the Business Connectivity Services runtime passes the mapped credentials from the Secure Store Service to the data source.

  1. Prerequisites:
  2. We can make sure that our user “HERCULESphill.duffy” can’t access to MS SQL database AdventureWorksLT2008

    Local user can’t access to MS SQL database

  3. Now we should configure Secure Store Service Application. Open Application Management in Central Administration and then Manage Service Applications. Click Secure Store Service Application. If you first time configure Secure Store Service Application, you will be prompted to generate a key because credential database is encrypted by using a key. In the future you will be able to re-encrypt the database using a new key. Click “Generate New Key” button on the ribbon. On the Generate New Key dialog, enter a pass phrase string in the Pass Phrase edit box, and type the same string in the Confirm Pass Phrase edit box. Click “OK”

    Encrypt the credential database using a new key

  4. Now we are ready to create new Secure Store Target Application.

    Create a new Secure Store Target Application

  5. Click “New” to create new Secure Store Target Application. Type your Target Application ID i.e. “MSSQLWinAuth”, fill in others fields and choose “Group” as your Target Application Type and click “Next”.

    Create a new Secure Store Target Application

  6. In order to specify the credential fields for your Secure Store Target Application leave the names for two new fields as default, and leave “Windows User Name” and “Windows Password” field types and click “Next”

    Specify the credential fields for your Secure Store Target Application

  7. Add Target Application administrator and then add the users and groups that will be mapped to the credentials defined for this Target Application. There is only one local user  in our case. Click “OK” button

    Add the users and groups that will be mapped to the credentials defined for this Target Application

  8. Click on created Target Application ID and you’ll see a drop down menu. Select “Set Credentials” item to set MS SQL impersonation credentials.

    Set MS SQL impersonation credentials

  9. Enter MS SQL username and password (used for Windows Authentication) that will be used for impersonation by created Secure Store Target Application. Click “OK” button

    Enter MS SQL username and password for impersonation

  10. Now we will create Business Data Connectivity Model file with BCS Meta Man and configure External Content Type to point to the “MSSQLWinAuth” Secure Store Target Application ID.
  11. Open Visual Studio 2010 (You should be logged in to Windows as entered user being used for impersonation. This is “HERCULESAdministrator” in our case)
  12. Add a New Project
  13. Expand the “SharePoint” node, select “Lightning Tools (2010)” node and then the “BCS Meta Man” project type
  14. Give your project a name i.e MSSQLSecureStoreBCSMetaManDemo and click “OK”

    Create MSSQLSecureStoreBCSMetaManDemo project

  15. On the next dialog box, enter the name of where you want to deploy your model, and click “Finish” button

    Deploy as a farm solution

  16. If prompted, click “Trial” on the licensing dialog
  17. To show the “BCS Meta Man Data Source Explorer” we need to enable it from the Menu item, this new window can be docked so it doesn’t get in your way

    Open the BCS MetaMan data source explorer

  18. Click the “Add Connection” button to show the “Connection Dialog”
  19. Select “SQL Server” as Data Source type, enter your MS SQL server name, choose “Use Secure Store – Windows Credentials” as Authentication Mode, enter created Secure Store Target Application ID and click “Connect” button

    Select SQL Server Data Source and enter Secure Store Target Application ID

  20. The Data Source Explorer will now be populated with your MS SQL data

    See the tables and views available to use

  21. We will be working with the “SalesLT”.”Address” table, to add it to the Model , just drag it from the “Data Source Explorer” onto the “Diagram”
  22. When you drop the table you will be shown the following dialog, we should choose “Database , click “OK”

    Choose the model type "Database"

  23. Accept the default entity name by clicking “Next”

    Accept the default entity name

  24. Accept the default “Identifiers” by clicking “Next”

    Accept the Identifiers selected

  25. Accept the default 3 methods to be created, click “Generate” (The default 3 methods are: “Finder” – Returns all items, “Specific Finder” – Returns a single item by identifier, “IdEnumerator” – Returns just the Identifiers for all of the items )

    Accept the methods

  26. Select menu “Build”->“Deploy Solution” in Visual Studio
  27. Now using this instructions BCS : Access Denied. You do not have permission to access this content we will set permissions to created External Content Type “SalesLT_Address” within SharePoint 2010 for our local user “HERCULESphill.duffy”

    Set permissions to External Content Type

  28. Now open your SharePoint page and login to the site as “HERCULESphill.duffy”. Add a new External List by selection on loaded SharePoint page “Site Action”->“More Options”->“External List”

    Add a new external list

  29. Click on the icon to show the available External Content Types

    Select the External Content Type

  30. Select our “MSSQLSecureStoreBCSMetaManDemo.SalesLT_Address” External Content Type, click “OK”

    Select the address External Content Type

  31. Click “Create”
  32. Your External System data from MS SQL database is now displayed in the SharePoint External List

    The data from MS SQL is now shown within SharePoint 2010

  33. If you login to the site as another user and browse created external list, you won’t be able to see the data

We hope this walkthrough will be useful for you. If you have any questions feel free to email them to support@lightningtools.com

Leave a comment