Skip to content

Commit

Permalink
Bug fixign for getting list of my sites method in the core component p…
Browse files Browse the repository at this point in the history
  • Loading branch information
VesaJuvonen committed Sep 1, 2014
1 parent 4072322 commit 2e438b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public static void InstallSolution(this Site site, Guid packageGuid, string sour
/// <returns>All my site site collections</returns>
public static List<SiteEntity> MySiteSearch(this Web web)
{
string keywordQuery = String.Format("contentclass:\"STS_Site\" AND site:{0}", web.Context.Url);
string keywordQuery = String.Format("contentclass:\"STS_Site\" AND WebTemplate:SPSPERS", web.Context.Url);
return web.SiteSearch(keywordQuery);
}

Expand All @@ -582,8 +582,9 @@ public static List<SiteEntity> SiteSearch(this Web web)
/// </summary>
/// <param name="web">Site to be processed - can be root web or sub site</param>
/// <param name="keywordQueryValue">Keyword query</param>
/// <param name="trimDublicates">Indicates if dublicates should be trimmed or not</param>
/// <returns>All found site collections</returns>
public static List<SiteEntity> SiteSearch(this Web web, string keywordQueryValue)
public static List<SiteEntity> SiteSearch(this Web web, string keywordQueryValue, bool trimDublicates = true)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ static void Main(string[] args)
{

// Office 365 Multi-tenant sample
ClientContext cc = new AuthenticationManager().GetSharePointOnlineAuthenticatedContextTenant("https://bertonline-my.sharepoint.com", "[email protected].com", GetPassWord());
ClientContext cc = new AuthenticationManager().GetSharePointOnlineAuthenticatedContextTenant("https://yourtenant-my.sharepoint.com", "keyzersoze@yourtenant.com", GetPassWord());

// Office 365 Dedicated sample - On-Premises sample
//ClientContext cc = new AuthenticationManager().GetNetworkCredentialAuthenticatedContext("https://my.microsoft.com", "bjansen", GetPassWord(), "europe");
//ClientContext cc = new AuthenticationManager().GetNetworkCredentialAuthenticatedContext("https://my.contoso.com", "keyzersoze", GetPassWord(), "contoso");

Console.WriteLine("----------------------------------------------------------------------");

Expand All @@ -29,16 +29,16 @@ static void Main(string[] args)
//List<SiteEntity> sites = cc.Web.SiteSearch();

// Lists site collections scoped to an URL
//List<SiteEntity> sites = cc.Web.SiteSearchScopedByUrl("https://bertonline.sharepoint.com");
//List<SiteEntity> sites = cc.Web.SiteSearchScopedByUrl("https://yourtenant.sharepoint.com");
// List site collections scoped by title
//List<SiteEntity> sites = cc.Web.SiteSearchScopedByTitle("test");

// if needed furhter refine the returned set of site collections
var bertSites = from p in sites
where p.Url.Contains("kevin")
select p;
var filteredSites = from p in sites
where p.Url.Contains("my")
select p;

foreach (var site in bertSites)
foreach (var site in filteredSites)
{
Console.WriteLine("Title: {0}", site.Title);
Console.WriteLine("Path: {0}", site.Url);
Expand Down

0 comments on commit 2e438b6

Please sign in to comment.