Operation requires user to be Service Application Administrator to be able to execute the code
Recently got a customer who was having a very simple code in an application page (in _layouts folder) to find the crawled properties, which are mapped to a managed property in Search Service Application (in SharePoint 2010) as given below: 1: SPServiceContext context = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default); 2: SearchServiceApplicationProxy searchProxy = context.GetDefaultProxy( typeof (SearchServiceApplicationProxy)) as SearchServiceApplicationProxy; 3: SearchServiceApplicationInfo ssai = searchProxy.GetSearchServiceApplicationInfo(); 4: SearchServiceApplication application = Microsoft.Office.Server.Search.Administration.SearchService.Service.SearchApplications.GetValue<SearchServiceApplication>(ssai.SearchServiceApplicationId); 5: Schema sspSchema = new Schema(application); 6: 7: ManagedPropertyCollection managedProperties = sspSchema.AllManagedProperties; 8: 9: foreach (ManagedProperty managedProperty in managedProperties) 10: { 11: string managedPropertyName = managedProperty.Name; 12: 13: //check to see if the managed property is mapped to one of our crawled properties 14: foreach (CrawledProperty crawledProperty in managedProperty.GetMappedCrawledProperties(managedProperty.GetMappings().Count)) 15: { 16: if (!mappings.ContainsKey(crawledProperty.Name)) 17: { 18: //if it is and has not yet been added to the list of managed fields, add it 19: mappings.Add(crawledProperty.Name, managedPropertyName); 20: 21: } 22: } 23: } Now when we hit the line 14 ( ManagedProperty.GetMappings() .Count), it always returns 0 (zero) as Mappings count. Now I am the Farm Administrator and the Service Account but still I am not able to pull in the data. If I am logging into SharePoint Central Admin, I am able to see all the mappings from the SharePoint UI.


