When using the API to create a site in a SPSSiteCollection, if you want the return to “portal” link to appear there is a couple of extra steps that you need to do not listed in the MS docs.

Thanks to Sharepoint Explorer, I found out what they are, but they have to be done in the correct order.

SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
SPSiteCollection sites = globalAdmin.VirtualServers[0].Sites;

newSiteCollection = sites.Add(“sites/NewSiteName”, “Title”, “Description”, 1033, “STS#0”,
“domain\user”, “Owner_User_Name”, “Owner_Email”);

newSiteCollection.PortalUrl = globalAdmin.VirtualServers[0].Sites[0].PortalUrl;
newSiteCollection.PortalName = globalAdmin.VirtualServers[0].Sites[0].PortalName;

The additional end two statements are required, the Url first, if this is not set you cannot set the PortalName and it does not throw and exception.

Many thanks to “Mad” ?(sp) for the article on getting these sites into the sites list and searchable.

http://weblogs.asp.net/mnissen/articles/207254.aspx

 

Advertisements