Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool Authenticate()
- {
- String username = "......";
- String password = "......";
- Cookie _authCookie;
- CookieContainer _cookieContainer;
- AuthService.Authentication authentication = new AuthService.Authentication();
- authentication.Url = "<web_url>/_vti_bin/Authentication.asmx";
- authentication.CookieContainer = new CookieContainer();
- authentication.AllowAutoRedirect = true;
- authentication.PreAuthenticate = true;
- AuthService.LoginResult loginResult = authentication.Login(username, password);
- _authCookie = new Cookie();
- if (loginResult.ErrorCode == AuthService.LoginErrorCode.NoError)
- {
- CookieCollection cookies = authentication.CookieContainer.GetCookies(new Uri(authentication.Url));
- _authCookie = cookies[loginResult.CookieName];
- _cookieContainer = new CookieContainer();
- _cookieContainer.Add(_authCookie);
- return true;
- }
- else
- return false;
- }
- AuthService.Authentication authentication = new AuthService.Authentication();
- authentication.Url = "<web_url>/_vti_bin/Authentication.asmx";
- authentication.CookieContainer = new CookieContainer();
- authentication.AllowAutoRedirect = true;
- authentication.PreAuthenticate = true;
- AuthenticationSoap authenticationSoap = null;
- authenticationSoap = authentication.getAuthenticationSoap();
- AuthServiceLoginResult loginResult = authenticationSoap.Login(username, password);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement