Advertisement
Guest User

Untitled

a guest
Jul 16th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. public bool Authenticate()
  2. {
  3. String username = "......";
  4. String password = "......";
  5. Cookie _authCookie;
  6. CookieContainer _cookieContainer;
  7.  
  8.  
  9. AuthService.Authentication authentication = new AuthService.Authentication();
  10. authentication.Url = "<web_url>/_vti_bin/Authentication.asmx";
  11. authentication.CookieContainer = new CookieContainer();
  12. authentication.AllowAutoRedirect = true;
  13. authentication.PreAuthenticate = true;
  14. AuthService.LoginResult loginResult = authentication.Login(username, password);
  15.  
  16. _authCookie = new Cookie();
  17.  
  18. if (loginResult.ErrorCode == AuthService.LoginErrorCode.NoError)
  19. {
  20. CookieCollection cookies = authentication.CookieContainer.GetCookies(new Uri(authentication.Url));
  21. _authCookie = cookies[loginResult.CookieName];
  22. _cookieContainer = new CookieContainer();
  23. _cookieContainer.Add(_authCookie);
  24. return true;
  25. }
  26. else
  27. return false;
  28. }
  29.  
  30. AuthService.Authentication authentication = new AuthService.Authentication();
  31. authentication.Url = "<web_url>/_vti_bin/Authentication.asmx";
  32. authentication.CookieContainer = new CookieContainer();
  33. authentication.AllowAutoRedirect = true;
  34. authentication.PreAuthenticate = true;
  35. AuthenticationSoap authenticationSoap = null;
  36. authenticationSoap = authentication.getAuthenticationSoap();
  37. AuthServiceLoginResult loginResult = authenticationSoap.Login(username, password);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement