Guest User

Untitled

a guest
Aug 28th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. var authenticationManager = new OfficeDevPnP.Core.AuthenticationManager();
  2. ClientContext context = authenticationManager.GetWebLoginClientContext(@"https://XXX-admin.sharepoint.com/", null);
  3. GetAllSiteCollections(context);
  4.  
  5. Message: The request was aborted: The request was canceled.
  6. InnerException: Microsoft.SharePoint.Client.IdcrlException: Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in.
  7. at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetUserRealm(String login)
  8. at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetServiceToken(String username, String password, String serviceTarget, String servicePolicy)
  9. at Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetAuthenticationCookie(Uri url, String username, SecureString password, Boolean alwaysThrowOnFailure, EventHandler`1 executingWebRequest)
  10. at Microsoft.SharePoint.Client.SharePointOnlineCredentials.GetAuthenticationCookie(Uri url, Boolean refresh, Boolean alwaysThrowOnFailure)
  11. at Microsoft.SharePoint.Client.SharePointOnlineAuthenticationModule.GetSpoAuthCookieAndUpdateRequest(WebRequest request, SharePointOnlineCredentials spoCredentials, Boolean preAuthentication)
  12. at Microsoft.SharePoint.Client.SharePointOnlineAuthenticationModule.Authenticate(String challenge, WebRequest request, ICredentials credentials)
  13. at System.Net.AuthenticationManagerDefault.Authenticate(String challenge, WebRequest request, ICredentials credentials)
  14. at System.Net.AuthenticationState.AttemptAuthenticate(HttpWebRequest httpWebRequest, ICredentials authInfo)
  15. at System.Net.HttpWebRequest.CheckResubmitForAuth()
  16. at System.Net.HttpWebRequest.CheckResubmit(Exception& e, Boolean& disableUpload)
  17. at System.Net.HttpWebRequest.DoSubmitRequestProcessing(Exception& exception)
  18. at System.Net.HttpWebRequest.ProcessResponse()
  19. at System.Net.HttpWebRequest.SetResponse(CoreResponseData coreResponseData)
  20.  
  21. private static void GetFilesPropertiesFromSite()
  22. {
  23. try
  24. {
  25. Console.WriteLine("Enter admin username: ");
  26. string username = Console.ReadLine();
  27. Console.WriteLine("Enter password: ");
  28. string password = Console.ReadLine();
  29.  
  30. var Uri = new Uri(@"https://XXX.sharepoint.com/sites/AL/");
  31. var credentials = PrepareSPOCredentials(username, password);
  32. var result = ExecuteSearchRequest(Uri, credentials, "contentclass:STS_ListItem AND ContentType:Task");
  33.  
  34. }
  35. catch (Exception ex)
  36. {
  37. Console.WriteLine("Message: " + ex.Message);
  38. Console.WriteLine("InnerException: " + ex.InnerException);
  39. }
  40. }
  41.  
  42. private static SharePointOnlineCredentials PrepareSPOCredentials(string userName, string passWord)
  43. {
  44. var securePassWord = new SecureString();
  45. foreach (var c in passWord.ToCharArray()) securePassWord.AppendChar(c);
  46. var credentials = new SharePointOnlineCredentials(userName, securePassWord);
  47. return credentials;
  48. }
Add Comment
Please, Sign In to add comment