403 error when listing the members of an audience

user682
  • 403 error when listing the members of an audience user682

    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>();
    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
        using (SPSite site = new SPSite("http://mysite"))
        {
            AudienceManager am = new AudienceManager(ServerContext.GetContext(site));
            foreach (UserInfo member in am.GetAudience("My Audience").GetMembership())
            {
                accounts.Add(member.NTName.ToLower());
            }
        }
    });
    

Tags
2007 error audience-targeting
Related questions and answers
  • I am using SharePoint Server 2007 Enterprise with Windows Server 2003 R2 Enterprise. I am developing using VSTS 2008 + C# + .Net 3.5 + IIS 6.0. I have put a simple aspx page into layout folder (the code is very simple, just redirect to another page, and I write inline script code in asp.net), here is my code, and I met with unauthorized error (403) when I select to browse the page from IIS 6.0 manager. I am not in Active Directory or Windows domain environment. I have enabled permission to anonymous users for the whole SharePoint site. Any ideas what is wrong? <%@ Page Language="C

  • } I also tried. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature.Parent as SPWeb; SPSecurity.RunWithElevatedPrivileges( () => { SPSite elevatedSite = new SPSite(web.Site.ID); elevatedSite.WebApplication.Features.Add( /*guid*/ ); //throws SecurityException }); } I don't understand why I would...My goal is to programmatically activate a Web Application scoped feature. I'm running this code from a feature receiver of a Web scoped feature. I'm logged in as a Farm Administrator. My app pool

  • = ""; SPSecurity.RunWithElevatedPrivileges(delegate { using (SPSite site = new SPSite(server)) { SPServiceContext context...; } This service gives a TimeOut error... When I delete the following line the TimeOut is fixed if (profile["FirstName"] != null) { } So I can only read out.... I see no other way to do this than to make a custom WCFService and deploy it to SharePoint. So that is what I did. I made an "Empty SharePoint Project" and added the mapped "ISAPI" folder. The code

  • + ASP.Net + SharePoint Server 2007 SDK. Here is my code snippets and I got error -- "Updates are currently disallowed on GET requests". Any ideas how to fix? Microsoft.SharePoint.SPException: Updates..."); } catch (Exception ex) { Response.Write(ex.ToString() + "\t" + ex.StackTrace); } } Update 1: I met with the same error...; } */ SPSite newSiteCollection = siteCollections.Add("sites/myblog", "New Sample Site", "New Sample Site Description", 1033, "BLOG#0", "foo\\foouser", "Owner name

  • I have developed a custom SharePoint web service, and deployed it to /_vti_bin/myservice.asmx. As a "regular" user, browsing to that ASMX URL works fine. When I try to browse to "/_vti_bin/myservice.asmx/js" as required to call this service from ASP.Net AJAX, I get a 403. If I browse to it as no less than a farm admin (site collection admin doesn't work), I get a 403. It is entirely possible... part code where I am hooking up the ASP.Net AJAX stuff: ScriptManager scriptMgr = new ScriptManager(); string webUrl = SPContext.Current.Web.Url; ServiceReference srvRef = new ServiceReference(webUrl

  • create a new Site Column using the SharePoint object model and happen to use http://server/path/site when instantiating the SPSite and SPWeb objects, the site column will be made available but when...Problem: Creating a site column using the SharePoint API (Object Model) with incorrect case in the URL for the SPSite or SPWeb object will cause the new column to throw an exception if an attempt... that is generated is bogus. Clear as mud? Example code: (this is a bad example because of the case sensitivity issue) // note: site should be partially caps: http://server/Path/Site using (SPSite site

  • I want to create a new SharePoint 2010 farm using PowerShell. I use the following command: New-SPConfigurationDatabase When issuing this command (and providing the needed parameters) I get the following error: New-SPConfigurationDatabase : This SharePoint farm currently has pending upgrades. The cmdlet New-SPConfigurationDatabase cannot be executed until the upgrade is completed. When running the "SharePoint 2010 Products Configuration Wizard" I'm able to create a farm. I have a freshly installed Windows Server 2008 R2 with SQL 2008 R2 on the same box (it's a demo box

  • When attempting to enable search query logging from the Shared Services Provider of my SharePoint 2007 farm, IIS returns the HTTP 403 error page. My account has full-control rights at the farm and site-collection levels.

  • as follows: Connections -> Send Program Entity Token To -> ... -> Get Program Entity ID From -> ... When I select a web part in "Get Program Entity ID From", a dialog appears for me to choose... and tested for providing a value via a connection. Is there anything that explains why I'm unable to set up a connection? Here is the code for my web part: public class ProgramEntityTokenConverter...) { EnsureChildControls(); List<;ConsumerParameter> parameters = new List<;ConsumerParameter>(); parameters.Add(new ConsumerParameter("ProgramEntityID

Data information