Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
Everyone i am new to session handling.Here I have developed web application where user can login using windows authentication.Also I have another web application which also uses windows authentication.i.e both application have same user name and password and both can login simultaneously.Problem is that when i logout from my web application it automatically logout from another application.
Is there is any solution please share with me.

What I have tried:

following code inside the session_start event
string windowsLogin = this.Context.Request.LogonUserIdentity.Name;


            //Normally if the domain is present you get a string like DOMAINNAME\username, remove the domain
            int hasDomain = windowsLogin.IndexOf(@"\");
            if (hasDomain > 0)
            {
                windowsLogin = windowsLogin.Remove(0, hasDomain + 1);
            } //end if 
           Session["UserName"] = windowsLogin;



then function for logout is javascript function
function Logout() {
          try {

              if (window.XMLHttpRequest) {

                  document.execCommand("ClearAuthenticationCache");

              }

              else {
                  alert("This feature requires Internet Explorer 6.0 Service Pack 1 or above. " + "Please close all browser windows in order to complete the logout process.");
              }
          }
          catch (e) {
              alert("This feature requires Internet Explorer 6.0 Service Pack 1 or above. " + "Please close all browser windows in order to complete the logout process.");
          }
          //netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
          //self.close();
          window.close();

      }
Posted
Updated 12-May-17 2:31am
Comments
F-ES Sitecore 12-May-17 8:09am    
If you're using Windows Authentication you're not supposed to offer a logout.
SujataJK 12-May-17 8:23am    
then what operation will be performed on logout link click?
F-ES Sitecore 12-May-17 8:29am    
None, you don't offer a logout function. They're still logged into Windows so they should still be logged into your website.
Richard Deeming 12-May-17 8:30am    
Your error message is wrong - XMLHttpRequest was added in IE7, not IE6 SP1.

ClearAuthenticationCache only works in IE, and will clear all Windows credentials for all sites from the current session.

AFAIK, there isn't a reliable way to do what you want with Windows authentication.

1 solution

Ummm... there is no way to "logout" of a web app that uses Windows Auth. The very next request will log the user right back in again since every request is sent with their security token and you can't change that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900