tags:

views:

131

answers:

0

I my case I have to do simple thing - iterate over search scopes. Important thing is that:

  • this is publishing site and nobody is logged into (anonymous access)

  • control behind code is in dll and ascx is in sharepoint controltemplate

  • dll with my behind code is registered in web.config as safe

In my control I have only simple code on Page_Load

SPSecurity.RunWithElevatedPrivileges(delegate() {

   SearchServiceApplication app = null;
   SPServiceApplicationCollection spscollection=
   SearchService.Service.SearchApplications;/

                         foreach (SPServiceApplication spsApp in spscollection)
                         {
                             app = (SearchServiceApplication)spsApp;
                             break;

                         }
                         Scopes scopes = new Scopes(app);
                         ScopeCollection sspScopes = scopes.AllScopes;
}

Result:

     System.UnauthorizedAccessException: Attempted to perform an

unauthorized operation. at Microsoft.Office.Server.Search.Query.UserVerification.ThrowIfNotSearchAdmin(SearchServiceApplication

searchApp) at Microsoft.Office.Server.Search.Administration.ScopeCollection.GetEnumerator() at MyControls.MyCustomControl.Page_Loadb__0()Attempted

to perform an unauthorized operation. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.