Ejemplo n.º 1
0
        public static CookieContainer GetCookiesByUserInfo(Uri siteUrl, string userName, string password)
        {
            var token = new SharePointOnlineCredentials(userName, GetPassword(password)).GetAuthenticationCookie(siteUrl);

            string          cookieName  = token.Substring(0, token.IndexOf('='));
            string          cookieValue = token.Substring(token.IndexOf('=') + 1);
            CookieContainer cookies     = new CookieContainer();

            cookies.Add(new Cookie(cookieName, cookieValue, "/", siteUrl.Host));
            return(cookies);
        }