2

I have configured fba in my site using thinktecture. When I click sign out or sign in as different user, sharepoint redirects me to following page:

/_login/default.aspx?ReturnUrl=%2f_layouts%2f15%2fAuthenticate.aspx%3floginasanotheruser%3dtrue%26Source%3d&loginasanotheruser=true&Source=

If I select windows authentication in dropdown, it redirect me to user homepage without prompting authentication dialogue.

For IE I got the solution like this:

document.execCommand("ClearAuthenticationCache");

but it's not working in chrome and mozilla. I have searched many sites on google but nothing help much.

I have tried following patch too.But nothing work for chrome and firefox.

Open Internet Explorer -> Tools - Internet options - > Local intranet Zone - > user Authentication ; Select - prompt For user name and password.

Thanks in advance.

1

you can not log out from SharePoint just setting a logout URL to your browser. I dug it a lot after that I found there is a session cookie which name is "FedAuth" is responsible for user logout as soon as you delete that cookie it will log out your session. it is a serverside session cookie so you can't find it out in document.cookie. you need to call a REST API to delete this cookie in server side. this approach I was following in Sharepoint on-Premise. but Sharepoint online I think it is not possible. or may be possible if you are able to delete "FedAuth" cookie.

enter image description here

0

Try following code samples.Any one should work:

1)

<script type="text/javascript">
function _spBodyOnLoad() {
    var PreviousPage = document.referrer.split('/')[3];      
    if (PreviousPage == "adfs") {
        var searchString = getQueryStringParameter('site');
        PreviousPage=searchString;
        }
    var browserName = navigator.appName.toLowerCase();
    if (browserName.indexOf("internet explorer") != -1) {
        document.execCommand("ClearAuthenticationCache");
        location.replace("/ABCD/SitePages/Page.aspx?site=" + PreviousPage);
        }
        else {
            var LogOutUrl = "https://ABCD/adfs/ls/?wa=wsignout1.0";
            location.replace(LogOutUrl);         
    }          
} 

function getQueryStringParameter(paramName) { 
    var searchString = window.location.search.substring(1); 
    var i; 
    var val; 
    var params = searchString.split("&"); 
    for (i = 0; i < params.length; i++) { 
        val = params[i].split("="); 
        if (val[0] == paramName) { 
            return val[1]; 
        } 
    }

    return null; 
} 

2)

<script language="javascript" type="text/javascript">
try{
  var agt=navigator.userAgent.toLowerCase();
  if (agt.indexOf("msie") != -1) {
    // IE clear HTTP Authentication
    document.execCommand("ClearAuthenticationCache");
  }
  else {
    // Let's create an xmlhttp object
    var xmlhttp = createXMLObject();
    // Let's get the force page to logout for mozilla
    xmlhttp.open("GET",".force_logout_offer_login_mozilla",true,"logout","logout");
    // Let's send the request to the server
    xmlhttp.send("");
    // Let's abort the request
    xmlhttp.abort();
  }
  // Let's redirect the user to the main webpage
  window.location = "/rest/";
} catch(e) {
// There was an error
alert("there was an error");
}

function createXMLObject() {
    try {
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        }
        // code for IE
        else if (window.ActiveXObject) {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    } catch (e) {
        xmlhttp=false
    }
    return xmlhttp;
}
</script>
  • can you tell me where should i place this code as i do not have custom sign out. we are using SharePoint given sign out . – love thakker Apr 9 '15 at 10:09
  • Try adding this is master page – 404 Apr 9 '15 at 10:15
  • I have implemented both the scripts. The first one does not give any result. When i put the second script, my site goes into an infinity loop. The page getting refresh. – love thakker Apr 9 '15 at 11:45
  • Did you try and debug the script? Because i am using the same script and is working fine. – 404 Apr 10 '15 at 4:26
  • It executes without error but go in to loop. I can't figure it out. – love thakker Apr 13 '15 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.