June 17
Anonymous Audiences in MOSS
In a past project, I needed to be able to create an audience in MOSS that would apply only to anonymous users in an SharePoint site configured to use forms-based authentication. Additionally, anonymous users could not access a page in SharePoint if the page contained a web part that was configured with an audience.
I noticed that the RuntimeFilter tag in the web.config file referenced the AudienceManager class:
<RuntimeFilter Assembly="Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Class="Microsoft.Office.Server.Audience.AudienceManager" BuilderURL="audience_chooser.aspx" />
Using Reflector, I was able to determine that this class was responsible for both supplying the audience controls in the tool part window and for determining whether or not the user was in the audience configured for the web part.
Normally, these controls are displayed when a web part is edited:
But after writing a wrapper for the AudienceManager class, I was able to add an additional checkbox to allow the user to specify that only anonymous users should see the webpart:
Now, when the user checks the check box, only anonymous users will see the web part. I also made an additional change to workaround the problem of anonymous users not being able to see pages that had web parts configured with audiences.
To implement the same functionality, you will need two classes: one that implements the Microsoft.SharePoint.WebPartPages.IRuntimeFilter2 interface and one that implements the Microsoft.SharePoint.WebPartPages.IToolPaneControl interface. The IRuntimeFilter2 interface is used to determine if the current user is in a particular audience when the web page is rendering and the class you create will need to be configured in the RuntimeFilter tag in the web.config file. The IToolPaneControl interface is used to display the audience control in the tool pane when the web part is edited.
You can download the code I used here.
Hur man fixar till anonym auditing i sharepoint