Tuesday, March 18, 2008

Master and supplementary data sources in Sharepoint 2007

The user profiles are a neverending source of issues, it seems! Get e-mails with all sort of questions regarding populating and using the user profile. Today, I’ll address the concept of master/supplementary data sources.

The basics
The User profile store contains the user account property information. This information is obtained by importing it from a directory or a data source that contains user accounts. MOSS 2007 can import a list of domain users from the Active Directory directory service, LDAP server, or the Business Data Catalog. In addition, you can write code against the object model to import information from other directory services or applications. You can schedule regular imports to the user profile store, and these can be incremental or full.

Master and supplementary data sources
But what if you need more data fields in your user profiles than your Active directory contains? What if you for instance have additional data in database or retrieved by a web service that you want to use for personalization or audience targeting? Office SharePoint Server 2007 treats Active Directory and LDAP directories as master connections for importing user information; that is, it can use them as a source to create user profiles. This master connection is responsible for adding and removing users from the user profiles database.
To add supplementary user profile info you use one or several supplementary data sources. They cannot add or remove users (like the master connection), but they can provide additional user information not available in the master connection. A Business Data Catalog data source is a typical supplementary data source.

There is a "preliminary" sample under way at http://msdn2.microsoft.com/en-us/library/ms585895.aspx. Also check out http://blah.winsmarts.com/2007-4-SharePoint_2007__BDC_-_User_Profiles.aspx.

© Copyright 2008, Tomas Elfving

6 comments:

John Mc said...

Hi Tomas, thanks for clearing that up for me. We'll be using AD as the master connection with supplemental details being imported from a SQL Server DB using the BDC. Will let you know how it goes ;)

Rick Taylor said...

ummm..*WHERE* exactly is this "great code example"? I have the SDK and it's not there.

Tomas Elfving said...

Good point, not in the "regular" SDK. Found it on http://msdn2.microsoft.com/en-us/library/ms585895.aspx, but its mot there now. In the meantime, check http://blah.winsmarts.com/2007-4-SharePoint_2007__BDC_-_User_Profiles.aspx, I'm also developing a solution myself, will post it here when its done next week.
Regards, Tomas

al said...

Thomas, thank you for the information, it's very useful. There is another question though. Is it possible to somehow pull up external data to be used as a set of possible values for a multi-select property in user profile? For example, lets say there is a property "My Interests" and we want to give users a limited set of values to choose from when filling out their profile. Is there a way to dynamically load those values from a database, or is the only available option to enter those by hand?

Tomas Elfving said...

Hi al!
MOSS 2007 supports multivalue properties. The this[] operator on the UserProfile object returns an ArrayList called UserProfileValueCollection. This code example shows you how to add multiple values to a multivalue property:

Add references to Microsoft.Office.Server, Microsoft.SharePoint and System.Web in your Microsoft Visual Studio project.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server;
using Microsoft.Office.Server.Administration;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using System.Web;

namespace UserProfilesApp
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://servername"))
{
ServerContext context =
ServerContext.GetContext(site);
UserProfileManager profileManager = new
UserProfileManager(context);
UserProfile profile =
profileManager.GetUserProfile("domainname\\username");

// Insert your database access code here!
profile["MyInterests"].Add((Object)"Soccer");
profile["MyInterests"].Add((Object)"Icehockey");
profile.Commit(); }
}
}
}

Good luck!

// Tomas

al said...

Oh ... this is great. Thanks a lot!