Guest User

Untitled

a guest
May 18th, 2018
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. The sign-in name or password does not match one in the Microsoft account system.
  2. at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetServiceToken(String securityXml, String serviceTarget, String servicePolicy)
  3. at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetServiceToken(String username, String password, String serviceTarget, String servicePolicy)
  4. at Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetAuthenticationCookie(Uri url, String username, SecureString password, Boolean alwaysThrowOnFailure, EventHandler`1 executingWebRequest)
  5. at Microsoft.SharePoint.Client.SharePointOnlineCredentials.GetAuthenticationCookie(Uri url, Boolean refresh, Boolean alwaysThrowOnFailure)
  6. at Microsoft.SharePoint.Client.ClientRuntimeContext.SetupRequestCredential(ClientRuntimeContext context, HttpWebRequest request)
  7. at Microsoft.SharePoint.Client.SPWebRequestExecutor.GetRequestStream()
  8. at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
  9. at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
  10. at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
  11. at SharePointLibrary.SPClient.GetAllUsers() in C:UsersbassiesourcereposTFSADVWKSPSharePointLibrarySPClientUsers.cs:line 39
  12.  
  13. public SPClient(string url)
  14. {
  15. baseUrl = url;
  16. var userName = ConfigurationManager.ConnectionStrings["SPsvcUsername"].ConnectionString;
  17. var password = ConfigurationManager.ConnectionStrings["SPsvcPassword"].ConnectionString;
  18. Trace.TraceInformation(userName);
  19. Trace.TraceInformation(password);
  20.  
  21. var securePassword = new SecureString();
  22. foreach (var c in password)
  23. {
  24. securePassword.AppendChar(c);
  25. }
  26. credentials = new SharePointOnlineCredentials(userName, securePassword);
  27. }
  28.  
  29. public IEnumerable<SharePointUser> GetAllUsers()
  30. {
  31. var spUsers = new List<SharePointUser>();
  32.  
  33. using (var clientContext = new ClientContext(baseUrl))
  34. {
  35. clientContext.Credentials = credentials;
  36.  
  37. var web = clientContext.Web;
  38. var list = clientContext.Web.SiteUserInfoList;
  39. var users = list.GetItems(new CamlQuery());
  40. clientContext.Load(users, includes => includes.Include(
  41. f => f["GUID"],
  42. f => f["FirstName"],
  43. f => f["LastName"],
  44. f => f["UserName"],
  45. f => f["Picture"],
  46. f => f.DisplayName));
  47.  
  48. clientContext.ExecuteQuery();
  49.  
  50. foreach (var user in users)
  51. {
  52. var imagePath = (FieldUrlValue)user.FieldValues["Picture"];
  53. spUsers.Add(new SharePointUser()
  54. {
  55. FirstName = (user.FieldValues["FirstName"] is string firstName) ? firstName : string.Empty,
  56. LastName = (user.FieldValues["LastName"] is string lastName) ? lastName : string.Empty,
  57. UserName = (user.FieldValues["UserName"] is string userName) ? userName.ToLower() : string.Empty,
  58. ImagePath = (user.FieldValues["Picture"] is FieldUrl pictureUrl) ? pictureUrl.ToString() : string.Empty,
  59. DisplayName = user.DisplayName
  60. });
  61. }
  62. }
  63.  
  64. return spUsers;
  65. }
Add Comment
Please, Sign In to add comment