/// <summary> /// This method will return a ClientContext object with the authentication cookie set. /// The ClientContext should be disposed of as any other IDisposable /// </summary> /// <param name="targetSiteUrl"></param> /// <returns></returns> public static SharePointLists.Lists GetAuthenticatedContext(string targetSiteUrl, int popUpWidth, int popUpHeight) { CookieCollection cookies = null; cookies = ClaimClientContext.GetAuthenticatedCookies(targetSiteUrl, popUpWidth, popUpHeight); if (cookies == null) return null; SharePointLists.Lists contexto = new SharePointLists.Lists(); try { contexto.CookieContainer = new CookieContainer(); foreach (Cookie cookie in cookies) { contexto.CookieContainer.Add(cookie); } } catch { if (contexto != null) contexto.Dispose(); throw; } return contexto; }
public RepositorioTarefas() { Contexto = ClaimClientContext.GetAuthenticatedContext(Constants.ENDRECO_SITE); Contexto.Url = Constants.ENDRECO_SITE + "/_vti_bin/Lists.asmx"; }