Windows Authentication : switching user

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Windows Authentication : switching user

    Hi,

    In my custom asp.net application (authentication = windows), I've
    tried to force a reauthentication after a button click by returning
    Response.StatusCode = 401;
    However instead of reauthenticating once, I'm asked for 3 times
    despite the correct userid and password.

    Is this due to certain configurations? Or is there any other
    alternative available to achieve the same effect?

    TIA,
    Simon
    Simon Guest

  2. Similar Questions and Discussions

    1. SQL / Windows Authentication Per User
      Does anyone know if it is possible to configure ColdFusion MX 6.1 Enterprise Server to connect to a SQL 2000 Server using Windows Authenitcation...
    2. Forms authentication <-> Windows user?
      Hi, I'm new in ASP.NET and I've got a question about authentication in an intranet application: I want to authentify and authorize the user by...
    3. ASP.net app with Windows authentication challenging one user only on second visit
      Hi All, I have an intranet application that uses ASP.net Windows authentication. It has been working flawlessly for the past year. Recently,...
    4. ASP.NET Forms Authentication Via A SQL Server Database With Windows User types?
      We have built an ASP.NET application that will run on the Intranet using SQL 2000 as our data layer. We have decided to use Form Authentication...
    5. User Session issue with ASP.NET Forms authentication & Windows 2003
      Hi, I first posted this query in just the aspnet ng but didn't get a reply so I'm posting here (probably more appropriate) Hope one of you guys...
  3. #2

    Default RE: Windows Authentication : switching user

    Simon,

    What does your code look like?

    Jim Cheshire, MCSE, MCSD [MSFT]
    ASP.NET
    Developer Support
    [email]jamesche@online.microsoft.com[/email]

    This post is provided "AS-IS" with no warranties and confers no rights.

    --------------------
    >From: [email]sturmel@polygon.ca[/email] (Simon)
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    >Subject: Windows Authentication : switching user
    >Date: 5 Apr 2004 07:12:15 -0700
    >Organization: [url]http://groups.google.com[/url]
    >Lines: 13
    >Message-ID: <66d063bc.0404050612.1fb70530@posting.google.com >
    >NNTP-Posting-Host: 206.47.108.35
    >Content-Type: text/plain; charset=ISO-8859-1
    >Content-Transfer-Encoding: 8bit
    >X-Trace: posting.google.com 1081174335 19558 127.0.0.1 (5 Apr 2004
    14:12:15 GMT)
    >X-Complaints-To: [email]groups-abuse@google.com[/email]
    >NNTP-Posting-Date: Mon, 5 Apr 2004 14:12:15 +0000 (UTC)
    >Path:
    cpmsftngxa06.phx.gbl!TK2MSFTNGXS01.phx.gbl!TK2MSFT NGXA05.phx.gbl!TK2MSFTNGP0
    8.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!
    news.maxwell.syr.edu!postnews1.google.com!not-for-mail
    >Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet.security: 9515
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    >
    >Hi,
    >
    >In my custom asp.net application (authentication = windows), I've
    >tried to force a reauthentication after a button click by returning
    >Response.StatusCode = 401;
    >However instead of reauthenticating once, I'm asked for 3 times
    >despite the correct userid and password.
    >
    >Is this due to certain configurations? Or is there any other
    >alternative available to achieve the same effect?
    >
    >TIA,
    >Simon
    >
    Jim Cheshire [MSFT] Guest

  4. #3

    Default RE: Windows Authentication : switching user

    It's really simple. I use an hyperlink to reload the page with a new URL
    parameter and then in my web page codebehind, I check if the parameter
    is not null. If so, I send a 401 to force the reauthentication.


    if( Request.QueryString["ChangeUser"] != null )
    {
    Response.StatusCode = 401;
    }

    I get the windows authentication dialog, but I have to click OK 3 times
    before it goes away. Apart from this, everything is fine, the user is
    changed.


    TIA,
    Simon

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Simon Turmel Guest

  5. #4

    Default RE: Windows Authentication : switching user

    Simon,

    I'll do some more looking as soon as I get a chance, but just right off, it
    could be due to the fact that you're not doing a Response.End after sending
    the status. For example:

    if(Request.QueryString["ChangeUser"] != null)
    {
    Response.Status = 401;
    Response.End;
    }

    Jim Cheshire, MCSE, MCSD [MSFT]
    ASP.NET
    Developer Support
    [email]jamesche@online.microsoft.com[/email]

    This post is provided "AS-IS" with no warranties and confers no rights.


    --------------------
    >From: Simon Turmel <sturmel@polygon.ca>
    >References: <8U4LnDyGEHA.3436@cpmsftngxa06.phx.gbl>
    >X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
    >Subject: RE: Windows Authentication : switching user
    >Mime-Version: 1.0
    >Content-Type: text/plain; charset="us-ascii"
    >Content-Transfer-Encoding: 7bit
    >Message-ID: <ejN4bWzGEHA.2708@TK2MSFTNGP11.phx.gbl>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    >Date: Mon, 05 Apr 2004 10:44:11 -0700
    >NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
    >Lines: 1
    >Path:
    cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT FEED01.phx.gbl!TK2MSFTNGP0
    8.phx.gbl!TK2MSFTNGP11.phx.gbl
    >Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet.security: 9517
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    >
    >It's really simple. I use an hyperlink to reload the page with a new URL
    >parameter and then in my web page codebehind, I check if the parameter
    >is not null. If so, I send a 401 to force the reauthentication.
    >
    >
    >if( Request.QueryString["ChangeUser"] != null )
    >{
    > Response.StatusCode = 401;
    >}
    >
    >I get the windows authentication dialog, but I have to click OK 3 times
    >before it goes away. Apart from this, everything is fine, the user is
    >changed.
    >
    >
    >TIA,
    >Simon
    >
    >*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    >Don't just participate in USENET...get rewarded for it!
    >
    Jim Cheshire [MSFT] Guest

  6. #5

    Default RE: Windows Authentication : switching user

    Hi,

    I tried with Response.End();, but still no success. I'll be waiting for
    your next idea.

    Thanks in advance,

    Simon



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Simon Turmel Guest

  7. #6

    Default RE: Windows Authentication : switching user

    Simon

    Are you sending a POST or a GET. Try a GET if you are sending a POST

    Hope it helps

    -Javier M

    Javier Miranda Guest

  8. #7

    Default RE: Windows Authentication : switching user

    There is no form here. Only a <a href=...>, so it is automatically a GET
    in this case.

    Simon

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Simon Turmel Guest

  9. #8

    Default RE: Windows Authentication : switching user

    Simon

    It seems like a problem with the URL parameter or HTTP headers. Can you clear/save the IIS log and paste it here after you recreate the behavior

    If you do so, remove any company data like IP address and ports before submitting it

    Hope it helps

    -Javier M.
    Javier Miranda Guest

  10. #9

    Default RE: Windows Authentication : switching user

    Here is my log file when I click to change the user. I think you should
    copy it to a notepad for a better reading.

    TIA,
    Simon


    2004-04-06 15:33:22 <IP> GET /PolygonIntranet/Home.htm ChangeUser=Y
    <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 2 2148074254
    2004-04-06 15:33:22 <IP> GET /PolygonIntranet/Home.htm ChangeUser=Y
    <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:22 <IP> GET /PolygonIntranet/Home.htm ChangeUser=Y
    <PORT> TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 5 0
    2004-04-06 15:33:23 <IP> GET /PolygonIntranet/Home.htm ChangeUser=Y
    <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:23 <IP> GET /PolygonIntranet/Home.htm ChangeUser=Y
    <PORT> TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 5 0
    2004-04-06 15:33:23 <IP> GET /PolygonIntranet/Home.htm ChangeUser=Y
    <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:23 <IP> GET /PolygonIntranet/Home.htm ChangeUser=Y
    <PORT> TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 5 0
    2004-04-06 15:33:23 <IP> GET /PolygonIntranet/Home.htm ChangeUser=Y
    <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:24 <IP> GET /PolygonIntranet/Home.htm ChangeUser=Y
    <PORT> TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 5 0
    2004-04-06 15:33:24 <IP> GET /PolygonIntranet/Templates/FrameHeader.aspx
    NRMODE=Published&NRORIGINALURL=%2fPolygonIntranet% 2fHome.htm&NRNODEGUID=
    %7b57AB4E5A-09BA-46A6-B893-4EDA82BFDD39%7d&NRCACHEHINT=ModifyLoggedIn&Ch
    angeUser=Y <PORT> TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 0
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/Templates/FrameNavigation.aspx
    NRMODE=Published&NRORIGINALURL=%2fPolygonIntranet% 2fHome.htm&NRNODEGUID=
    %7b57AB4E5A-09BA-46A6-B893-4EDA82BFDD39%7d&NRCACHEHINT=ModifyLoggedIn&Ch
    angeUser=Y <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 2 2148074254
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/Templates/FrameNavigation.aspx
    NRMODE=Published&NRORIGINALURL=%2fPolygonIntranet% 2fHome.htm&NRNODEGUID=
    %7b57AB4E5A-09BA-46A6-B893-4EDA82BFDD39%7d&NRCACHEHINT=ModifyLoggedIn&Ch
    angeUser=Y <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:24 <IP> GET
    /NR/exeres/57AB4E5A-09BA-46A6-B893-4EDA82BFDD39,frameless.htm
    ChangeUser=Y <PORT> TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 0
    2004-04-06 15:33:24 <IP> GET /PolygonIntranet/Styles/VikingMenu.css -
    <PORT> TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 0
    2004-04-06 15:33:24 <IP> GET /PolygonIntranet/Styles/Viking.css - <PORT>
    TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 0
    2004-04-06 15:33:24 <IP> GET /PolygonIntranet/Images/VikingLogo.JPG -
    <PORT> TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 64
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/CommonClient.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 2 2148074254
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/CommonClient.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/CommonClient.js - <PORT>
    TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 0
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/Windows.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 2 2148074254
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/Windows.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/Windows.js - <PORT>
    TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 64
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/Console.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 2 2148074254
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/Console.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/Console.js - <PORT>
    TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 64
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/OptionsClient.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 2 2148074254
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/OptionsClient.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/OptionsClient.js - <PORT>
    TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 64
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/JavaScriptUIStrings.js - <PORT> -
    <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 2 2148074254
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/JavaScriptUIStrings.js - <PORT> -
    <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/JavaScriptUIStrings.js - <PORT>
    TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 64
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/Dates.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 2 2148074254
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/Dates.js - <PORT> - <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    401 1 0
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/CMS/WebAuthor/Client/Dates.js - <PORT>
    TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 64
    2004-04-06 15:33:24 <IP> GET
    /PolygonIntranet/Templates/FrameNavigation.aspx
    NRMODE=Published&NRORIGINALURL=%2fPolygonIntranet% 2fHome.htm&NRNODEGUID=
    %7b57AB4E5A-09BA-46A6-B893-4EDA82BFDD39%7d&NRCACHEHINT=ModifyLoggedIn&Ch
    angeUser=Y <PORT> TESTSERVER\administrator <IP>
    Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CL R+1.1.4322)
    200 0 0


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Simon Turmel Guest

  11. #10

    Default RE: Windows Authentication : switching user

    Simon

    I am just looking the log. Is this OK?... " /PolygonIntranet/Home.htm ChangeUser=Y
    Notice that the page is HTML. Is ASP.NET processing the file including code?

    I noticed many 401... what a discovery ah!, but take a look at the parameter. Still there. Can you try a sesion variable instead of parameter


    Javier Miranda Guest

  12. #11

    Default RE: Windows Authentication : switching user


    It is processing the ASP.net code, it's a web application working with
    Microsoft CMS. The aspx are the templates that htm use. I'll try with a
    session variable and tell you the result soon.

    Simon


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Simon Turmel Guest

  13. #12

    Default RE: Windows Authentication : switching user

    I have now tried with a session variable and I have the same problem. If
    anyone has an idea, please post it.


    TIA,
    Simon



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Simon Turmel Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139