Recently a client asked to that all Site Collections that are created are automatically connected to the main corporate portal using the Portal Site Connection Setting (Site Actions -> Site Settings -> Portal Site Connection)
To do this in code is very simple as shown below which is actually triggered when a Feature gets activated:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPSite site = properties.Feature.Parent as SPSite)
{
PortalLog.LogString("Activating feature for: " + site.PortalName + " at URL: " + site.PortalUrl);
site.PortalUrl = "http://corporate.portal.com";
site.PortalName = "Corporate Portal";
}
}
And thats it you can now you can set this in code and maybe do what we did and attach it to various site templates.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.

