« Previous Next »

Thread: IIS is not returning the correct LOGON_USER info

Last post 06-09-2005 12:38 PM by qbernard. 11 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (12 items)

Sort Posts:

  • 04-11-2005, 11:26 PM

    • Rach513
    • Not Ranked
    • Joined on 01-13-2004, 5:51 PM
    • Posts 0

    IIS is not returning the correct LOGON_USER info

    I am having a problem with Request.ServerVariables["LOGON_USER"]. My application needs to get the userid from logon_user and perform a query against the database . So, this application works fine when I run it on the local machine.

    But interestingly, when I port the code to a remote server, it returns the userid from Logon_user but performs the query with some cached id.

    I tried doing everything like turning of anyonymous access, turning on Integrated authentication and turning on basic authentication etc. Doesn't make any difference.

    I read somewhere on one of the web server forums about some roaming profiles in Active Directory being the reason for that and asking them to turn it off. I am not sure how to tackle this with that. Can anyone throw some light on this? Or give any other piece of advice?

     

  • 04-12-2005, 8:21 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,234
    • IIS MVPs

    Re: IIS is not returning the correct LOGON_USER info

  • 04-12-2005, 4:04 PM In reply to

    • Rach513
    • Not Ranked
    • Joined on 01-13-2004, 5:51 PM
    • Posts 0

    Re: IIS is not returning the correct LOGON_USER info

    This is my code block. When I hard code the Id it works. it's only when I use Request. ServerVariables.

     

    <%

    SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString2"]);

    myConnection.Open();

    SqlCommand cmd = new SqlCommand("SP1",myConnection);

    cmd.CommandType = CommandType.StoredProcedure;

    string user = HttpContext.Current.Request.ServerVariables["LOGON_USER"];

    Response.Write("Logged in User:" + user);

    cmd.Parameters.Add("@NTAccount",SqlDbType.NVarChar,255).Value = user; //HttpContext.Current.Request.ServerVariables["LOGON_USER"];

    SqlDataAdapter da = new SqlDataAdapter(cmd);

    DataSet ds = new DataSet();

    da.Fill(ds);

    myConnection.Close();

    DropDownList1.DataSource = ds;

    DropDownList1.DataBind();

    %>

    Thanks.

    Rach

  • 06-01-2005, 11:11 PM In reply to

    • PeterBrunone
    • Not Ranked
    • Joined on 06-19-2002, 9:15 AM
    • I'm standing behind you.
    • Posts 0

    Re: IIS is not returning the correct LOGON_USER info

    Any chance this remote server has compression enabled?  That will often cache pages at the server level, so the first person to access it sets the version everyone else sees.

    Go into IIS (MMC) and right-click the machine, pick properties, select the web service, and go to the Service tab.

    If none of the compression boxes are checked, there's a chance that there may be a caching setting in the web.config or machine.config on the errant box.
    Peter Brunone
    MS MVP, ASP.NET
    Founder, EasyListBox.com
    Do the impossible, and go home early.
  • 06-02-2005, 8:28 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,234
    • IIS MVPs

    Re: IIS is not returning the correct LOGON_USER info

    Don't know why I didn't respond to this earlier but ...

    shouldn't it be with "( )" as in Request.ServerVariables("LOGON_USER")?

    Also, you need to disable anonymous access and force authentication in order for this to get populated.
  • 06-02-2005, 2:24 PM In reply to

    • PeterBrunone
    • Not Ranked
    • Joined on 06-19-2002, 9:15 AM
    • I'm standing behind you.
    • Posts 0

    Re: IIS is not returning the correct LOGON_USER info

    C# uses brackets for array and collection elements.

    Peter Brunone
    MS MVP, ASP.NET
    Founder, EasyListBox.com
    Do the impossible, and go home early.
  • 06-02-2005, 3:47 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,234
    • IIS MVPs

    Re: IIS is not returning the correct LOGON_USER info

  • 06-03-2005, 2:00 PM In reply to

    • bhavin78
    • Not Ranked
    • Joined on 09-24-2004, 9:25 AM
    • USA
    • Posts 3

    Re: IIS is not returning the correct LOGON_USER info

    I am running a website from my local pc with IIS installed. In my code I get user information using user.identity.   It's working fine from my pc. when I move that code to live iis server, for some reason it does not get user identity. any reason for this. please help me figure this out. IIS is configured to use windows intgergrated authentication. This same configuration worked for a while and it stopped working today.
  • 06-07-2005, 8:59 PM In reply to

    Re: IIS is not returning the correct LOGON_USER info

    Mm.. it returns as blank ? if yes, it looks like it's not using non-anonymous login. If you check the username field in IIS log file, does it capture any user name ?
    Cheers,
    Bernard Cheah
  • 06-08-2005, 9:20 AM In reply to

    • bhavin78
    • Not Ranked
    • Joined on 09-24-2004, 9:25 AM
    • USA
    • Posts 3

    Re: IIS is not returning the correct LOGON_USER info

    How do I make use of non-anonymous login? do I need to  un-check anonymous acces in directory security configuration.

    how do I check IIS log file for user name?

  • 06-08-2005, 2:13 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,234
    • IIS MVPs

    Re: IIS is not returning the correct LOGON_USER info

    That's one way to do it.  Consult your IIS documentation for the full reference on authentication.  The log file will show a "-" for anonymous access and the username in cases where the client has authenticated.
  • 06-09-2005, 12:38 PM In reply to

    Re: IIS is not returning the correct LOGON_USER info

    Try -
    PRB: Request.ServerVariables("LOGON_USER") Returns Empty String
    http://support.microsoft.com/?id=188717
    Cheers,
    Bernard Cheah
Page 1 of 1 (12 items)
Microsoft Communities