User Profiles and Audience Targeting

Posted on 1/14/2007 @ 2:37 PM in #SharePoint by | Feedback | 53289 views

Carl Franklin and I recorded DNRTV #3 on SharePoint 2007 last weekend. This show was targeted towards ASP.NET 2.0 Developers, and we dove into two specific aspects

a) Interacting with the API

b) Writing Custom Web Parts

The show, should be online in about a month's time. Meanwhile, you can check out my code-magazine articles and and articles, and of course my blog about writing custom webparts. I have talked quite a bit about writing webparts, but the other portion - interacting with the API, I haven't talked much about (atleast publicly).

In this DNRTV show #3, I talked about interacting with the API, and the specific example I choose was a couple of utilities I have written with help from Angus Logan (Microsoft Australia), and will be available on These utilities target user profiles and profile properties, but before I dive into what these utilities are all about, let me explain the background and set a stage for the need for these utilities.

If you are already familiar with User Profiles and Audience Targeting, then dive straight to the bottom of this blogpost where I talk about these tools that promise to make your life easier in production environments.

So lets start. First let us talk about "User Profiles".

User Profiles

MOSS 2007 has a fantastic feature called "User Profiles". Put simply, your MOSS 2007 sites and site collections will be accessible by a set number of users. These users will be split up into groups, and the key differentiation between each user will be their login_id (account name). Out of the box, you can use Windows Authentication, but still there is a primary key of sorts that differentiates one user from another. However, in any organization, a user is more than just a login_id. He has an address, a phone number, email, his manager, HR information, and a number of other things. In other words, a user has a "profile".

This "profile" information is generally stored under a number of systems in an organization - it could be a SAP system, a database, Active Directory, GAL (outlook/exchange), and others. Whatever it may be, SharePoint 2007 provides you with a convenient way to synchronize such user profile information from such stores of information. I have blogged earlier about a step by step process of syncrhonizing such information on both a full import basis and an incremental import basis. Without going into those details in this blogpost, in short, you can import such profile information from Active Directory, Active Directory Resource, LDAP or BDC. BDC further implies that you can import information from anything that has a web service, or can be accessed using ADO.NET. In addition to an import, you can specify mapping. So, "Postal Code" in your SAP HR system may mean "ZipCode" in SharePoint - so on and so forth.

The obvious question here is, what benefit can you garner from having all this profile information synchronized from multiple "islands of information" within your organization? An obvious benefit is, your users now get a "face". Literally, having a full user profile means, you see something like -

... rather than, "MyDomain\Smalik". (Curious about my picture?)

Also, right off the bat, alerts will work because you now have a proper email address associated, you are able to do hierarchical org charts, and a number of other benefits. The really cool thing however is that you can define custom properties, and you can do "Audience Targeting".

Audience Targeting

Audience Targeting refers to the ability, that you as a user can create content, targeted to certain audiences. It is as easy as this, Once you have imported profile information into MOSS 2007, you can say, Create an audience of users that are in California, and Report to Joe Schmoe. This becomes an audience called "Joe Schmoe's croonies in California". Now, Joe Schmoe, or anyone else, can target content to only that group of individuals.

How is this done, you ask? Here is how.

  1. All this magic lives under Shared Services. So go ahead and under Central Admin, open Shared Services for the web you wish to create audiences on.
  2. Click on the link that says "Audiences".
  3. Under "Audiences" create a new audience, specify the rest of the information. I am going to create an Audience called "Smart People".
  4. Next, SharePoint will ask you to choose rules for that audience. Go ahead and specify some rules. Rules, as you would notice, let you segregate the audiences based on a certain specific user, or group, or based on a property value. You would note that the properties you see in the dropdown, are the same properties you defined in the user profile properties collection. (Read that again - this is where light bulbs should go off). I am going to create a single rule, where personal site contains "winsmarts".
  5. When you are done specifying the rules, go ahead and click "Compile Audience". In my case, there was one guy (me), who matched the criterion - whose personal site included the word "winsmarts", so the "Smart People" audience is now populated with one single user - me (how convenient). LOL.

My audience is now setup, and you can see this as below -

With my audience setup, the next obvious question is, "How can I use this audience?". In other words, if I had  really complex concept that I wished to communicate to only "Smart People", how would I do it? easy.

  1. Setup a list.
  2. Go to List Settings, and under "Audience Targeting Settings" check the checkbox that says "Enable Audience Targeting".
  3. Now, go ahead and add a List Item, you should see "Target Audiences" as one of the information(s) you can specify.
  4. Type in the necessary information, specify "Smart People" as the target audience. This is show as below on a list of type "Calendar" -

Now when you click "OK", this content will appear to only people who are of target audience "Smart People". In other words, if a user has "winsmarts" as a part of his personal website, he will see this content - others won't.

That, I gotta say, is pretty incredibly powerful.

What about those tools then?

At the beginning of this blogpost, I talked about a couple of tools I have written, with help from Angus Logan (Microsoft Australia), that make your "user profiles" life easier. The two tools are as follows -

a) The first tool allows you to easily transfer profile properties from one web to another web.
b) The second tool, allows you to easily transfer actual profiles based on these proeprties from one web to another web.

These are very very useful if you are moving your site deployment between development and production, or from intranet to extranet, or any other such scenario.

My next couple of blog posts will walk you through these two utilities, how I wrote them, and the code will be available on very very shortly.

Sound off but keep it civil:

Older comments..

On 2/23/2007 7:55:44 PM Pete said ..
Hi Sahil,

I have put in place a list which is utilising audience targeting however the list items still show to all users. It seems to be that audience targeting only restricts item display when it is set in the Content Query Web Part or when you specify an audience for a web part as a whole. Is this right or have I missed something?



On 2/23/2007 8:14:06 PM Sahil Malik said ..
Pete -

Did you compile the audience? If you import/export the site - how big is the export file after you zip it?


On 3/4/2007 11:46:34 PM Matt Hamilton said ..
G'day Sahil,

This was a fantastic post, but I'm afraid that I had a similar to experience as Pete. I've created an "announcements" list and posted some news items to it, targetting them both at an audience which I know has been compiled, and just now I noticed on someone else's PC that they can see the news items even though they're not a member of the audience.

Is there something we're missing?

On 3/5/2007 12:09:17 AM Matt Hamilton said ..
Ah - got it! Audience Targetting does nothing on the list to which the items are posted. It's only Content Queries that "roll up" that information elsewhere that can filter based on audience. Now it makes sense!

On 5/29/2007 2:32:32 AM saritha said ..
hi sahil i have dont with the things u mentioned above wat i need is ki when one particular user loggs in from one audience when they do content search only documents targeted to that audience need to display not others how to do that

On 5/29/2007 5:44:25 PM Ben said ..
We have imported users from AD into SharePoint, but when we click on an individual user to see their profile, we get an error message stating, "an error was encountered while retrieving user profile details." We get this error message on every user profile.

Have you encountered this before?

On 6/18/2007 4:36:15 PM Tom said ..
Enabling Audience Targeting seems to only work with a content query doing the rollup. If a user simply selects the list itself, they see everything. Silly.

The net effect of this is that, in the case of an Announcements list, you have to hide the list everywhere so users don't dig around and see things they aren't supposed to see. This actually seems to be a hard thing to do as in order for a non audience member to see general info in the list, they need read permission to the list which unhides it from the quick launch.

On 12/17/2007 12:49:29 PM Ange said ..
I have a question about security of User Profiles... In my organization I have 2 groups of users. Each group will have an administrator that needs permission to edit user information for any user that falls in their
group but they must not see (or edit) users of the other group.
Note: Also Users cannot modify their own profiles.

How would I accomplish this? Audiences using a filter on a custom user profile property?

On 3/11/2008 1:04:47 AM Nizar said ..
Although I imported some profiles manually, when I go & click on a user (whose profile exist) I get this error : "an error was encountered while retrieving user profile details." . I can only see the details of the administrator ... HEELP ME PLEAASE

On 4/3/2008 12:15:31 AM Rany said ..

I've tried what you have recommended and it does work. The problem is when you use the query web part you get a link to the list item which by default has a link to the full list.

On 4/4/2008 1:52:05 PM Shelton Davis said ..
I seem to be having a very difficult problem. I am able to create an audience with no problem. Set up the rules with no problem. I click the start compilation and it doesn't seem to work. Does anyone know how to fix this problem.

On 8/11/2008 5:43:13 AM Frankie said ..
I have my sharepoint box/SQLServer BOX/AD box all in my DMZ. My DMZ AD is configured only as a lookup to look up for account information on our internal AD. How can I go about inporting all the profiles from the internal AD into DMZ Sharepoint?

On 9/18/2008 5:45:03 AM Raj said ..

I need to have a web part visible to a limited users. I have created a group for the set of people and then imported the group into MOSS.

Then using the modify shared web part, I am trying to set the Target Audience property to that group.But, it does not work.Even the targeted Audience users are not able to see the web part.

I am not able to understand what went wrong.

It would a great help if you could guid me with the issue.

Thanks in anticipation

On 6/30/2009 10:26:02 AM Deepti said ..
Hi, I have some problem in targeting audiences for list item. Can anyone help ? I am able to do target audiences for my site items. Please any suggestions will be helpful.

On 12/7/2009 12:21:39 PM Nick said ..
Hi Sahil,

We are using Windows auth for internal users and FBA for external access. The same user may access the site internally one day, and externally the next. We need to maintain enhanced profiles for both access points. I can import using an AD connection, so that all of the "DOMAIN\username" profiles show up, or I can import with my membership provider so that all of the "LdapMembership:username" profiles show -- but I can't seem to do both, since the one overwrites the other. The only way I can get both profiles is by letting SP handle the AD users, automatically creating profiles as they access the site, and configuring the import to use my Ldap provider. This would seem to indicate that the automatically generated profile is using a different identifier than the profile brought in by either the AD or LDAP import. And of course, the automatically generated profile is lacking critical properties that our system relies upon.

My questions to you are:

1. Do we really need to have seperate profiles for each user based on access point & auth method?

2. If so, is there a way to modify the automatic import to bring in the required properties?

3. OR... is there a way to use the profile import process to bring in both AD and LDAP profiles for the same user?

Sorry for necroing such an old thread, I hope you are out there somewhere and may have an answer for me!



On 2/26/2010 6:04:59 PM Pen Moor said ..
Audience targetting is a convenience feature, not a security feature - don;t forget you can hide those individual posts, etc. using the permissions feature on the list itself if you are desperate to hide a specific item.

On 3/3/2010 7:28:18 PM Khadija Ahmed said ..
Hi Sahil

I was wondering if you could help me with setting up target audience for surveys in MOSS 2007? Also can we actually specify target audience for each questions in the survey?

On 3/8/2010 6:10:38 AM Darren said ..
You can also target an auudience on any webpart. Log in as an Admin, select modify web part/under advanced, right at the bottom you'll see the audience section. Browse/select your audienc and click OK. Now only people in that audience will see the web-part on the page! Nice eh!

On 3/14/2010 10:07:38 AM Alkis Spyrou said ..
Hello Sahil,

Well done on the great posting!

I have a query:

How can I add a single name/user/person in the target audience field of MOSS2007?

Currenlty I am only allowed to add a MOSS group.

However, many times there are a number of individual persons (that are in the same group) that I would like to add as audience.

On 6/27/2010 9:54:21 PM Vishwas Setty said ..
Hi Sahil,

We at the company are working on Migrating from 2007 to SP 2010. And our client have a global LDAP Directory which stores all the users, groups information. There is a requirement for using Audience in SP 2010? But out of the box SP 2010, the Audience targeting works with AD Domain, So was wondering if you could help me with some ideas on how we can work with Audience in 2010? Probably a class or a namespace that we need to use and a brief steps explaining how it can be implemented.

Thank you very much for your time