.Net操作Sharepoint常用方法(3) 获取Client Context
public static ClientContext GetClientContext(Guid SPListId) { ClientContext resultClientContext = null; OfficeDevPnP.Core.AuthenticationManager authManager = new OfficeDevPnP.Core.AuthenticationManager(); try { using (var clientContext = authManager.GetNetworkCredentialAuthenticatedContext(ConfigurationHelper.GetSPSiteURL(), ConfigurationHelper.GetSPUserAccount(), ConfigurationHelper.GetSPUserPassword(), ConfigurationHelper.GetDomainName()) { bool listExists = clientContext.Web.ListExists(SPListId); if (listExists == true) { resultClientContext = clientContext; } } } catch (Exception ex) { } return resultClientContext; }