Page view counter

Windows Authentication: Logout

Last post 04-30-2007 2:36 AM by XiaoYong Dai – MSFT. 3 replies.

Sort Posts:

  • Windows Authentication: Logout

    04-26-2007, 5:07 AM
    • Loading...
    • ahmadlead
    • Joined on 04-26-2007, 8:26 AM
    • Posts 2
    • Points 0

    Hi,

    I have a website where Windows Authentication is used to log in the site. I have used ASP.NET 2.0. I need to add a button "Logout" that will close the session and bring the windows authentication window in response to click event.

    Any Suggestion Please!

  • Re: Windows Authentication: Logout

    04-26-2007, 11:45 AM
    • Loading...
    • gbarnett
    • Joined on 02-05-2006, 4:05 PM
    • UK
    • Posts 112
    • Points 831

    Hmmm, this sounds like IE may help you.  If you tick the prompt for win user login creds in IE the user should thne be asked to login with a pop-up box, however, logging out I'm not too sure about - presumably you only want them to log out of the site not windows?

    Give the IE bit a go and see if that is what you are thinking of...why would you want explicit logging out though of something that uses win auth? 

    HTH.

  • Re: Windows Authentication: Logout

    04-27-2007, 2:17 AM
    • Loading...
    • ahmadlead
    • Joined on 04-26-2007, 8:26 AM
    • Posts 2
    • Points 0

    Thanks for the reply. Actually I need a logout button that will close the current session, and again will show the windows authentication dialog box so that user can again login if required. And without relogging in user can't access any page of the site. But I still don't know how to do this.

     

  • Re: Windows Authentication: Logout

    04-30-2007, 2:36 AM
    Answer

    Hi

    As far as I know, it's not possible to clear/change Windows credentials in .NET code. That is due to setting of IIS & IE. What we can do is to send a 401 HTTP status code and ask the client to re-input the user credential:

             string strUser = User.Identity.Name;

             if (strUser.Contains("olduser"))

            {

                Response.StatusCode = 401;

            }

            else

            {

                …

            }

    Best Regards
    XiaoYong Dai
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Page 1 of 1 (4 items)