Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. private void RemoveCookiesAndRedirect()
  2. {
  3. string ipUrl = GetIPUrl();
  4. //if (ipUrl != string.Empty)
  5. //{
  6. string replyUrl = HttpUtility.UrlEncode(SPContext.Current.Site.RootWeb.Url);
  7. string redirect = ipUrl + "?wa=wsignout1.0&wreply=" + replyUrl;
  8.  
  9. try
  10. {
  11.  
  12. FederatedAuthentication.SessionAuthenticationModule.SignOut();
  13.  
  14. if (Context.Session != null) Context.Session.Abandon();
  15.  
  16. Context.Response.Redirect(redirect);
  17. //}
  18. }
  19. catch (Exception ex)
  20. {
  21. LoggingService.LogError("LoginRedirect", ex.Message + " " + ex.InnerException + " " + ex.Data + " ipUrl:" + ipUrl + " redirect:" + redirect);
  22. }
  23. }
  24.  
  25. private string GetIPUrl()
  26. {
  27. IClaimsPrincipal user = Page.User as IClaimsPrincipal;
  28. if (user == null) return string.Empty;
  29.  
  30. string ipUrl = string.Empty;
  31. try
  32. {
  33. string providerName = (user.Identity.Name).Split('|')[1];
  34. ipUrl = SPSecurityTokenServiceManager.Local.TrustedLoginProviders[providerName].ProviderUri.AbsoluteUri;
  35. }
  36. catch
  37. {
  38. //TODO:Log it
  39. }
  40. return ipUrl;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement