Welcome! This is way long overdue. Many thanks first to Rob Holmes for his generous encouragement to get started sharing SharePoint tips and insights. I kid around (partially) that Microsoft spends billions to make me look good. Well, as much as I just love SharePoint, it leaves an awful lot to one’s creativity to deliver world-class user solutions. At times it feels like mud-wrestling with an octopus in the pitch black, but I will try to shed some light in a few corners. People shouldn’t make the same mistakes twice; heck, they shouldn’t make the same mistakes once! Enough rambling, let’s tackle an interesting problem.
Audiences are popular for targeting web parts and content, in fact they tend to be overused, where a true security model should be utilized. Audience Management is buried within the User Profile Service (UPS). Viewing Audience membership is one at a time. How can one easily document Audience membership? Well, there’s a way to quickly generate a report of Audiences and their members. The trick is a few lines of PowerShell; first the commands for those who just want to get started, then I’ll explain how they work, and some pitfalls to avoid:
This will output to a file called “AudienceDetail.txt” a list of your Audiences, and for each Audience, it will output all the members of the Audience. Note to use this you must:
- Be a Farm Admin
- RDP onto the SharePoint box
- Be an administrator of the User Profile Service (Full Control)
- THIS IS THE BIG TRICK: you must also grant yourself “Publishing” permissions to the User Profile Service (see “Sharing” tab in Central Admin for the UPS). Normally this is only ever used for publishing a Service Application to be consumed by another farm. Full Control is indeed required.
The first step is grabbing a hold of a Site Collection; any one will do. We use that to use .NET Reflection to grab the Server Context. That allows us to then grab the Audience Manager Object Class, which is the entry point for audience features in SharePoint , from which we can output the Audiences.
Admittedly, the server context class is deprecated in SP2010, but it works and does the trick.
There is indeed another way to get this information, which is to examine the “Profile DB” database, which has a set of tables with the odd name “Orgle” that contains the Audience information as well as the rules for compiling Audiences:
With a SQL View constructed from the Orgle tables, it would be easy to display a dynamic PivotTable in SQL web part or an Excel Services Pivot Table.