internal ClientContext CloneContext(string url) { var context = ContextCache.FirstOrDefault(c => new Uri(c.Url).AbsoluteUri == new Uri(url).AbsoluteUri); if (context == null) { context = Context.Clone(url); try { context.ExecuteQueryRetry(); } catch (Exception ex) { #if !ONPREMISES && !NETSTANDARD2_0 if ((ex is WebException || ex is NotSupportedException) && CurrentConnection.PSCredential != null) { // legacy auth? var authManager = new OfficeDevPnP.Core.AuthenticationManager(); context = authManager.GetAzureADCredentialsContext(url.ToString(), CurrentConnection.PSCredential.UserName, CurrentConnection.PSCredential.Password); context.ExecuteQueryRetry(); } else { #endif throw; #if !ONPREMISES && !NETSTANDARD2_0 } #endif } ContextCache.Add(context); } Context = context; return(context); }
public ClientContext CloneContext(string url) { var context = ContextCache.FirstOrDefault(c => HttpUtility.UrlEncode(c.Url) == HttpUtility.UrlEncode(url)); if (context == null) { context = Context.Clone(url); try { context.ExecuteQueryRetry(); } catch (Exception ex) { if (ex is WebException || ex is NotSupportedException) { // legacy auth? var authManager = new OfficeDevPnP.Core.AuthenticationManager(); context = authManager.GetAzureADCredentialsContext(url.ToString(), CurrentConnection.PSCredential.UserName, CurrentConnection.PSCredential.Password); context.ExecuteQueryRetry(); } else { throw; } } ContextCache.Add(context); } Context = context; return(context); }