I have seen a couple of cases where then end users where having an issue with the "Related Sites" search scope within a SharePoint Portal Site. By default, when you create a Collaboration Portal, the following 3 Search Scopes show up when you first load the page:
This Site: Home
These are the 3 main scopes that get pulled in from the SSP within a SharePoint farm. "This Site" would be considered a Contextual Scope and is specific to searching for content only within the context of that site. If you were to browse to the "Related Links scope settings" within a site and add an addtional search scope, based on another URL, like http://microsoft.com, and then re-compile your scopes manually or let the SSP scope compilation complete automatically (every 15 minutes by default). When you go back to the home page your site, you should see a "Related Sites" search scope in the drop down. This is all good if you intend to utilize this search scope, but the issue comes to surface when you decide that you no longer want to have any "Related Sites" search scopes within that site. So lets say you perform the following actions to remove the related links:
- Browse to the site you want to remove the Related Links from via, http://fqdn.domain.com/_layouts/RelLinksScopeSettings.aspx
- Click on the Selected Links you want to remove ( all in this case) and for each one, you click on "Remove"
- You click on OK and suspect all is good.
- Wait for the Scopes to compile on their own or manually force the compilation via http://servername:6000/ssp/admin/_layouts/searchsspsettings.aspx and then click on "Update Scopes"
- reset IIS to clear the cache
- Browse back to the site and you notice the "Related Sites" is still in the drop down.
At this point you would expect the "Related Sites" to disappear, so you browse back to the /_layouts/RelLinksScopeSettings.aspx page and see the words "emptytext" in the "Available Links"section of the page. This gives the impression that a scope exists in the site so this is why the "Related Sites" scope is still present in the search drop down.
So you ask, how can I get rid of this at this time? It is not really causing any real problem other than maybe some confusion for the end users who are trying to search for information within this site. While there is not a direct way through the UI to remove this from the search scopes, I can provide you some sample Object Model code that you or a developer can compile and run against the site URL and get that to disappear from the drop down. Again this is Sample Code and has no warranty and is not supported by Microsoft. This code will basically identify the WebID within the content database for the site URL you want to remove the "related sites" link from and then correleate that GUID with the Scopes in the SSP DB and delete the item from the database. After this is completed, it is necessary to go ahead and update the scopes and then do an IISReset in order to flush the compiled pages from memory. Below is the Sample Code you can use to remove the "Related Sites" scope from a site"
· We basically created a Form Box for the GUI
· Then compile the code below:
public partial class Form1 : Form
if (textBox1.Text.Trim() == "")
MessageBox.Show("Please enter the root web URL.");
SPSite site = new SPSite(textBox1.Text);
SPWeb myweb = site.OpenWeb();
Guid mywebid = myweb.ID;
// MessageBox.Show("webid : " + mywebid.ToString());
Uri siteuri = new Uri(site.Url);
Microsoft.Office.Server.ServerContext myservercontext = Microsoft.Office.Server.ServerContext.GetContext("SSP");
SearchContext scontext = SearchContext.GetContext(myservercontext);
Scopes sspscopes = new Scopes(scontext);
ScopeCollection allscopes = sspscopes.AllScopes;
Scope myscope = null;
Scope MydeleteScope = null;
IEnumerator myscopeenum = sspscopes.AllScopes.GetEnumerator();
for (int i = 0; i < allscopes.Count; i++)
myscope = (Scope)myscopeenum.Current;
if (myscope.Name == mywebid.ToString())
MydeleteScope = myscope;
if (MydeleteScope == null)
MessageBox.Show("Related sites scope for site " + myweb.Name + "(" + textBox1.Text + " ) does not exist.");
MessageBox.Show("Related sites scope for site " + myweb.Name + "( " + textBox1.Text + " ) deleted successfully");
private void Form1_Load(object sender, EventArgs e)
** Please note that where I have highlighted “SSP” you will need to replace that value with the name of your SSP
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
' Please stress test this code before deploying it in a production environment.
' This is intended as a sample of how code might be written for a
' similar purpose. This code has not been tested. This code is
' also not to be considered best practices or prescriptive guidance.
' It is highly recommended that you FULLY understand what this code is doing
' and use this code at your own risk.
' Copyright (C) Microsoft Corporation, 2009
· Once this is compiled and executed browse to your SSP Admin Site
· Click on Search Settings:
· Find the Scopes Section and click on “Start Update Now”
· Once that has been updated go into your WFE server(s) and recycle the application pools for the Web App you just executed this against.
After the page has been rendered again, you should see that the “Related Sites” option is no longer present in the Search Drop Down Box
To confirm that the scope has been deleted, you can open up SQL Server Management Studio and then run the following queries to see that the GUID for that scope has been removed from the SSP Database.
- First you would need to get the WebId from the content DB that you ran the code against
- Open SQL Server Management Studio and create a New Query
- In the drop down, next to the "execute" function in the toolbar, make sure you have the Content Database select
- Then run the following:
- Identify the Id where root of that site exists.
- Copy this GUID and put it into notepad
- Then create a new query and this time make sure the SSP DB is selected, not the Search DB, but the SSP DB
- Then run the following:
select * from MSSScopes
- If the GUID is still present in that table, then you have not successfully removed the scope. If it is no longer present, then the "Related Sites" scope should no longer be there when the Scopes are Updated and IIS has been reset.
I hope this helps in the event you want to get rid of that "Related Sites" scope within your Search Drop Down!