2 out of 2 rated this helpful - Rate this topic

Microsoft.Office.Server.Audience namespace

Contains classes that create audiences and target data to a specific audience.

In addition to rules-based audiences, you can implement targeting based on SharePoint groups and distribution list (DL) memberships. You can also target content to the list item level, rather than just to the list level.

Note Note

You can use a web service that finds all SharePoint sites that are targeted to a particular user. For more information, see How to: Use the Published Links Web Service.

Example 1: Getting the AudienceManager Object in SharePoint Server

The AudienceManager object is the top-level object in the Audience object model. You can get an AudienceManager object by using the syntax shown in the following code example. Replace servername with an actual value and add any code that you might need before using this example.

using (SPSite site = new SPSite("http://servername"))
 {
   ServerContext context = ServerContext.GetContext(site);
   AudienceManager audManager = new AudienceManager(context);
   //your code here
 }

Example 2: Personalized Portals

The following code example shows how to target list items to a particular audience.

    AudienceLoader audienceLoader = AudienceLoader.GetAudienceLoader();
   foreach (SPListItem listItem in list.Items)
   {
    // Get roles the list item is targeted to.
     string audienceFieldValue = (string)listItem[k_AudienceColumn];

    // Quickly check if the user belongs to any of those roles.
     if (AudienceManager.IsCurrentUserInAudienceOf(audienceLoader, audienceFieldValue, false))
                {
                    // is a member
                }
                else
                {
                    // not a member
                }
  }
  ClassDescription
Public classAudienceRepresents an audience on a SharePoint site.
Public classAudienceAccountNameNotResolvedExceptionRepresents an exception that is thrown when the Audience account name is not valid.
Public classAudienceADImportExceptionRepresents the exception thrown when an error occurs while getting data from Microsoft Active Directory directory service.
Public classAudienceArgumentExceptionRepresents the exception thrown when invalid data is supplied to the AudienceCollection and AudienceSiteCollection classes.
Public classAudienceCollection Represents a collection of audiences for a portal site.
Public classAudienceCollection.AudienceEnumeratorRepresents the enumerator for Audience objects in the AudienceCollection object.
Public classAudienceConnectionExceptionRepresents the exception thrown when an error occurs when connecting to the database.
Public classAudienceDataValueOutOfRangeExceptionRepresents an exception thrown when a data value is out of range.
Public classAudienceDataWrongFormatExceptionRepresents an exception that is thrown when the Audience data is in the wrong format.
Public classAudienceDuplicateNameExceptionRepresents the exception thrown when a user tries to create or rename an audience to a name that already exists in the database.
Public classAudienceExceptionRepresents the base class for audience exceptions.
Public classAudienceExecutionExceptionRepresents the exception thrown when an error occurs when executing an audience operation, such as creating, removing, or updating an audience.
Public classAudienceGroupOperationExceptionRepresents an exception thrown when an error is encountered in the audience while performing a group operation.
Public classAudienceInCompilationExceptionThrows an exception when a user tries to change audience data while audience rules are compiling.
Public classAudienceJobProvides a method to start and stop full and incremental audience compilations
Public classAudienceLeftContentRepresents the operand content of an audience rule.
Public classAudienceManagerRepresents the entry point for the audience classes.
Public classAudienceNameDescriptionLengthExceptionRepresents an exception that is thrown if the length of the audience name exceeds 50 characters or if the description exceeds 254 characters.
Public classAudienceNameIDRepresents a synopsis of information about an audience, such as the name and GUID, and whether the audience is still valid.
Public classAudienceNoContentExceptionRepresents an exception thrown by the AudienceManager object when an error is encountered while retrieving data.
Public classAudienceNotExistExceptionImplements the exception thrown when an audience cannot be found in the database.
Public classAudienceOperatorRepresents the definition of an audience operator.
Public classAudienceOperatorExceptionRepresents the exception thrown by the Audience class and AudienceManager class when an operator error is encountered for a rule definition.
Public classAudienceOwnerAccountNameLengthExceptionRepresents an exception thrown when the length of the owner account name exceeds 400 characters.
Public classAudienceRuleComponentRepresents one rule in an audience.
Public classAudienceRuleLeftContentExceptionRepresents the exception thrown when an error is encountered in the operand portion of an audience rule.
Public classAudienceRuleRightContentExceptionRepresents the exception thrown by the AudienceRuleComponent class when an error in encountered in the rule definition.
Public classAudienceSiteRepresents an entry point for accessing the audience associated with a portal site.
Public classAudienceSiteCollectionRepresents a collection of portal sites that are associated with a specific audience.
Public classAudienceSiteCollection.AudienceSiteEnumeratorEnumerates sites in the AudienceSiteCollection class.
Public classAudienceSiteInfoRepresents information for a specific instance of the AudienceSite class in addition to the Microsoft.Office.Server.ServerContext object associated with the portal site.
Public classAudienceWrongAccountNameFormatExceptionRepresents the exception that is thrown when the wrong account name format is encountered in an audience rule.
Public classEmptyToolPaneControlThis class and its members are reserved for internal use and are not intended to be used in your code.
Public classMembershipInfoStores information from Microsoft Active Directory directory service about a user or group.
Public classUserInfoRepresents user information from a user's user profile, such as e-mail address and name.
  EnumerationDescription
Public enumerationAudienceAccessRightsRepresents the access rights one can have on audiences.
Public enumerationAudienceGroupOperationSpecifies the operations that can be performed on an audience that has more than one rule.
Public enumerationAudienceJobReturnCodeIndicates the status of the RunAudienceJob method call.
Public enumerationAudienceTypeRepresents the type of the audience.
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.