In the Sharepoint Interpreter, there are two different ways of iterating through the SPWebApplications on the server:
- SPWebApplicationProbe
if (SPWebService::ContentService != nullptr) {
SPWebApplicationCollection^ webApplicationCol = SPWebService::ContentService->WebApplications;
for each (SPWebApplication^ webApp in *webApplicationCol)
- SPCrawlRuleProbe
SPWebServiceCollection wsColl(SPFarm::Local);
for each (SPWebService ^ws in wsColl) {
for each (SPWebApplication ^app in ws->WebApplications) {
Do these return the same set of SPWebApplications?
I would say they don't in general return the same web applications. One iterates over a collection of SPWebService's, and one gets a single SPWebService. Which is correct depends on how we should define the scope of the search and what SPWebService::ContentService actually returns. The MSDN docs for the latter say "Gets the Web service associated with the content application." which doesn't explain well enough for me.
The correct way is the method in SPCrawlRuleProbe. SPWebService::ContentService only returns the SPService that holds the content applications (notably omitting the Central Administration application, which is owned by SPWebService::AdministrationService).
I have corrected the SPWebApplicationProbe.