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

Audience Class

Represents an audience on a SharePoint Server 2010 site.


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

[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class Audience

Audiences are groups of users determined by their memberships in Microsoft Exchange distribution lists (DL) or SharePoint groups, or by rules configured by a portal administrator. For example, you can set up new employees, executives, salespeople, or people from a specified city as audiences. In SharePoint Server 2010, you can base the audience rules on information in the user profile, on membership in an Active Directory directory service security group or an Exchange distribution list, or on the organization's reporting structure (if this information is kept in Active Directory).

Audiences allow organizations to target content to users based on their job or task, as defined by their membership in a SharePoint group or distribution list, by the organizational reporting structure, or by the public properties in their user profiles.

SharePoint Server 2010 supports targeting based on audience, SharePoint groups, and DL memberships. In addition, SharePoint Server 2010 provides the ability to target to the list-item level, rather than just to the list level.

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. Compiling audiences is not supported in the object model.

Replace servername and other strings with actual values before running the code example. Also add the following references in your 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"))
                    ServerContext context = ServerContext.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)
                        //Add your exception handling code here.
                    catch (AudienceException e1)
                        //Add 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