Microsoft.Office.Server.Audience 命名空间
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.
备注
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("https://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
}
}
类
枚举
枚举 | 说明 | |
---|---|---|
![]() |
AudienceAccessRights | 表示一个可以对访问者的访问权限。 |
![]() |
AudienceGroupOperation | 指定访问群体,有多个规则可执行的操作。 |
![]() |
AudienceJobReturnCode | 表明RunAudienceJob方法调用的状态。 |
![]() |
AudienceType | 表示类型的访问群体。 |