Collaboration-2-Go


Lösungen und Software-Entwicklung im Collaboration Umfeld, insbesondere Microsoft SharePoint, Microsoft Exchange und Microsoft Office.

Support


Mobil: +49 (152) 53 97 78 79
Mail: service@collaboration-2-go.de
Weitere Kontaktmöglichkeiten: Kontaktseite
Dekoration: Köln



Activate Feature using CSOM
Created: 19.04.2015
Categories: SharePoint 2013; SharePoint Development

Add references to Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime.

Code:

string url = "https://sharepoint/sites/teamsite";
string domain = "myDomain";
string login = "myLogin";
string pwd = "myPassword";
// feature id for MySite Newsfeed webpart:
Guid feature = new Guid("6928B0E5-5707-46a1-AE16-D6E52522D52B");

using (var ctx = new ClientContext(url))
{
    ctx.AuthenticationMode = ClientAuthenticationMode.Default;
    ctx.Credentials =
      new System.Net.NetworkCredential(login, pwd, domain);
    var features = ctx.Site.Features;
    ctx.Load(features);
    ctx.ExecuteQuery();
    features.Add(feature, true, FeatureDefinitionScope.None);
    ctx.ExecuteQuery();
}


This way you I'm able to activate hidden features or start a bulk activation.
    

Post a Comment!