none
Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in. RRS feed

  • Question

  • Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in. 

    string cookieString = credentials.GetAuthenticationCookie(targetSite);

    trying to get data from the list 

    using Microsoft.SharePoint.Client;
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Security;
    using System.Text;
    using System.Threading.Tasks;
    using System.Xml;
    using System.Xml.Linq;
    using System.Web.Services;
    using System.Web;





    namespace MailFuntionality
    {
        class Program
        {
           
           public static CookieContainer GetO365CookieContainer(SharePointOnlineCredentials credentials, string targetSiteUrl)
            {
                Uri targetSite = new Uri(targetSiteUrl);
                string cookieString = credentials.GetAuthenticationCookie(targetSite);
                CookieContainer container = new CookieContainer();
                string trimmedCookie = cookieString.TrimStart("SPOIDCRL=".ToCharArray());
                container.Add(new Cookie("FedAuth", trimmedCookie, string.Empty, targetSite.Authority));
                return container;

            }
            
            public static SharePointOnlineCredentials GetO365Credentials(string userName, string passWord)
            {
                SecureString securePassWord = new SecureString();
                foreach (char c in passWord.ToCharArray()) securePassWord.AppendChar(c);
                SharePointOnlineCredentials credentials = new SharePointOnlineCredentials(userName, securePassWord);
                return credentials;
            }
          
            static EmailHelper emailHelper = new EmailHelper();
            static void Main(string[] args)
            {
                Getmail();
           
            }
            public static void Getmail()
            {
                string username = ConfigurationSettings.AppSettings["loginUser"].ToString();
                string domain = ConfigurationSettings.AppSettings["Domain"].ToString();
                string password = ConfigurationSettings.AppSettings["Password"].ToString();
                string webserevice = ConfigurationSettings.AppSettings["webserevice"].ToString();
                MailFunctionality.Lists listService = new MailFunctionality.Lists();
                listService.Url = webserevice;
                SharePointOnlineCredentials credentials = GetO365Credentials(username + "@" + domain, password);
                CookieContainer cc = GetO365CookieContainer(credentials, webserevice);
                listService.CookieContainer = cc;
        
                System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
                string listName = "TestMail";
                string rowLimit = "250";
                System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
                System.Xml.XmlElement viewFields =  xmlDoc.CreateElement("ViewFields");
                System.Xml.XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
                query.InnerXml = "<Query></Query>";
                viewFields.InnerXml = "";
                queryOptions.InnerXml = "";
                System.Xml.XmlNode nodeListItems = listService.GetListItems(listName, null, query, viewFields, null, queryOptions, null);

               
            }

            public static void sendmail(string title, string type, string Date)
            {
                string Subject, Body, Regards, containt, From, toNames, ccNames;




                From = ConfigurationSettings.AppSettings["from"].ToString();
                Regards = ConfigurationSettings.AppSettings["Regards"].ToString();

                Body = "<div> <b> Dear Sir   </br></br></b>  ";
                
                    toNames = ConfigurationSettings.AppSettings["To"].ToString();
                    ccNames = string.Empty;
                    Subject = ConfigurationSettings.AppSettings["ReminderSubject"].ToString() + "-" + title;
                    //containt = " <b> Reminder !!!  </b> </br></br> " + ConfigurationSettings.AppSettings["ReminderBody"].ToString() + "-" + "<b>" + title + "</b>" +
                     //  "<br>  The Excepted Closure date is  " + "<b>" + Date + "</b>";
                   // Body = Body + containt + "<br><br> <b> Thanks & Regards,<br><br>" + Regards + " </b></div>";

                    //    string[] cc = ccNames.Split(';');
                    string[] to = toNames.Split(';');

                    emailHelper.SendMail(Subject, Body, From, to);
               

                //emailHelper.SendMail(
            }
           
       
        }
    }
     



    Vishal

    Wednesday, August 12, 2015 7:19 AM

Answers