Re: HTTP 401.2 - Unauthorized: Logon failed due to...

From: Desmond Lam (deslam_at_online.microsoft.com)
Date: 03/17/04


Date: Wed, 17 Mar 2004 12:21:56 +0800

Just a quickly reply from top of my mind:

Try to hardcode a least priviledge local account in your code connection
string. Make sure the mdb's ACL contains the local account with write
access.

I beleive there should be other (better) alternatives.

Hope it helps
Desmond

"Newbie" <anonymous@discussions.microsoft.com> wrote in message
news:43B3040F-B1B4-4ED0-8673-02F9339B9642@microsoft.com...
> I have set up an ASP script (with some help from
microsoft.public.inetserver.asp.general!) that grabs the windows username of
the user and puts it into an Access database.
>
> It is setup on IIS5 as a virtual directory and will only be used
internally on our network.
>
> The script works fine with the authentication set as "basic
authentication" but this prompts the user for a login and password.
>
> I want it to be automated which I believe would use the "Integrated
Windows Authentication". However when I select this I get the following
error below. I think the answer may lie in adding some headers to my ASP
code, but as an ASP newbie I don't really know where to start with that.
I've included my ASP code at the bottom for reference.
>
> Thanks
>
> --------------------------------------------------------------------------
------
> HTTP 401.2 - Unauthorized: Logon failed due to server configuration
> Internet Information Services
> --------------------------------------------------------------------------
------
>
> Technical Information (for support personnel)
>
> Background:
> This is usually caused by a server-side script not sending the proper
WWW-Authenticate header field. Using Active Server Pages scripting this is
done by using the AddHeader method of the Response object to request that
the client use a certain authentication method to access the resource.
>
> --------------------------------------------------------------------------
------
> CODE:
> <% @ Language="VBScript" %><%'force authentication- put this at top of ASP
code
>
> 'declare your variables
> dim connection
> dim sSQL,sConnString
> dim Username
>
> If Request.ServerVariables("LOGON_USER") = "" Then
> Response.Status = "401 access denied"
> End If
> Username=(Request.ServerVariables("LOGON_USER"))
>
>
> 'declare SQL statement that will query the database
> 'sSQL="INSERT INTO Log (FirstName, SurName) VALUES (Username, 'Wall')"
>
> sSQL="INSERT INTO Log (Name) VALUES ('" & replace(Username,"'","''") &
"')"
>
>
> 'define the connection string, specify database
> ' driver and the location of database
> sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
> "DBQ=" & Server.MapPath("ServerLog.mdb") & ";"
>
> 'create an ADO connection object
> Set connection = Server.CreateObject("ADODB.Connection")
>
>
> 'Open the connection to the database
> connection.Open(sConnString)
>
> 'execute the SQL
> connection.execute(sSQL)
>
> 'check to see if there were any errors
> If err.number=0 Then
> response.write "the data was inserted successfully."
> Else
> response.write "there was a problem entering the data."
> End If
>
> 'close the object and free up resources
> Connection.Close
> Set Connection = Nothing
> %>



Relevant Pages

  • Re: Apache mod_rewrite/RewriteMap prg: and perl script
    ... > input for some hours and then go on (especially if the database is on ... > a remote box - tcp connection might have gone dead for whatever ... What *does* happen is that the script gets garbled. ... different garble each time you hit it. ...
    (comp.unix.admin)
  • Re: ADO Connection Timeout
    ... so what happens when a connection failure forces one station to revert ... to a local database? ... Further, you *will* have contention issues, Jet does not support record ... to the central server, but you are willing to live with periods where it ...
    (microsoft.public.data.ado)
  • Need help with ASP script.
    ... the beginning process of having a webpage that will direct students to ... I had downloaded a free ASP script which basically uses a ... 'Check the database to see if user exsits and read in there password ... 'Database connection info and driver ...
    (microsoft.public.inetserver.asp.general)
  • Re: Difference between storing files on folder and in mysql db
    ... a separate instance of an image display script (and a separate ... connection if images were stored in the file system. ... know or care if the image is from a database or not. ... but the DB server does. ...
    (comp.lang.php)
  • Re: ADO Connection Timeout
    ... When the first test is run, the results are stored in the central database. ... to the central server, but you are willing to live with periods where it ... i.e. a local database or even a text file. ... to function until the connection can be restored to the server. ...
    (microsoft.public.data.ado)