SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following code runs fine as an administrator but crashes with a 403 forbidden error when run as a non-admin on the am.GetAudience("My Audience") call. Can anyone spot why, I'm running with elevated privileges?

List<string> accounts = new List<string>();
    using (SPSite site = new SPSite("http://mysite"))
        AudienceManager am = new AudienceManager(ServerContext.GetContext(site));
        foreach (UserInfo member in am.GetAudience("My Audience").GetMembership())
share|improve this question
bizarrly, using Audience a = am["My Audience"] works without elevating privileges.... – user682 May 18 '10 at 8:56
I guess you mean am.Audiences["My Audience"]? This is because GetAudience calls an internal method CanAccess() that checks for UserProfileApplicationAdminRights and throws an UnauthorizedAccessException if you are not allowed to manage audiences. If you use the Audiences collection index remember to place the code inside a try/catch and catch the AudienceArgumentException to avoid the code to break if an audience does not exist. You see similar behaviour on User Profile Manager – Anders Rask Oct 25 '11 at 8:31

Not that I have actually tried this, but I suspect the problem could be because the call to elevate priveliges only elevates up to the web application pool service account - this account may not have permission to access your SSP (which is where the audiences are managed).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.