Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

AudienceManager class

Represents the entry point for the audience classes.


Namespace:  Microsoft.Office.Server.Audience
Assembly:  Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)

[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel = true)]
public class AudienceManager : IRuntimeFilter2, 

The AudienceManager class is the entry point for the audience feature in Microsoft SharePoint Server 2010. It provides an implementation of IRuntimeFilter, which allows Web Parts and other content to be targeted to a specific audience. The AudienceManager class supports run-time functionality such as the retrieval of audience lists to which the user belongs. After you create an instance of the AudienceManager class, you can retrieve individual audience types, lists of audiences, and lists of users who are associated with an audience.

There are several default authentication rules and scopes implemented for the AudienceManager object:

  • Members of the Administrator site group for SharePoint Server can view and modify the audiences associated with a portal site.

  • Members of the Administrator site group can also view audience information for other portal sites with which they share services. Shared services are portal services that are shared across server farms. The services are centrally managed from a single server for two or more server farms.

  • Members of the Administrator site group of the parent portal site can list and view audience information for child portal sites. This information is read-only.

  • A member of the Reader or Contributor site group can access only a list of audiences to which he or she belongs. This information is returned by the overloaded GetUserAudienceIDs method.

This code example shows how to create a rules-based audience to which you can target content.


The audience is only created here; it is not compiled, and rules have not been added. You can add rules by using the user interface or the object model, and then compile the audience by using the user interface. You can also compile audiences by using the AudienceJob class.

Replace servername and other strings with actual values before running the code example. Also add the following references in your Microsoft Visual Studio project:

  • Microsoft.Office.Server

  • Microsoft.SharePoint

  • System.Web

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

namespace AudienceConsoleApp
    class Program
        static void Main(string[] args)
                using (SPSite site = new SPSite("http://servername"))
                    SPServiceContext context = SPServiceContext.GetContext(site);
                    AudienceManager audManager = new AudienceManager(context);

                    AudienceCollection ac = audManager.Audiences;
                    Audience a = null;
                    string sAudName = "Customer Connection";
                    string sDescription = "Members of the Customer Connection v-team";

                        a = ac.Create(sAudName, sDescription);
                    catch (AudienceDuplicateNameException e)
                        //Your exception handling code here
                    catch (AudienceException e1)
                        //Your exception handling code here

            catch (Exception exception)


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft