need  manually set IIS authentication to use only windows integrated authentication(uncheck the anonymous authentication), and make sure you or the user account has enough rights on your search service.

queryService.Credentials = new System.Net.NetworkCredential(“username”,“password”,“domain”);

or you may want to try different passing

queryService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

or

NetworkCredential networkCredential = CredentialCache.DefaultCredentials.GetCredential(new Uri(queryService.Url), “NTLM”);
or

queryService.Credentials = networkCredential;

 queryService.Credentials = System.Net.CredentialCache.DefaultCredentials;
queryService.PreAuthenticate = true;

Advertisements