Re: WebClient + Credentials + HTTP 401 Status Codes

From: Raterus (raterus_at_hotmail.com)
Date: 02/10/05


Date: Thu, 10 Feb 2005 12:58:40 -0500

I modified my code to use WebRequest and set PreAuthenticate=True, and you are right, it still won't preauthenticate with integrated windows authentication. Now i'm wondering why? Would WebRequest be authenticating with Kerberos or NTLM? I'd imagine it is using NTLM, and since that is challenge/response that would make sense why I can't preauthenticate. I don't even want to know what it would take to get WebRequest to use Kerberos!

--Michael

"Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com> wrote in message news:%23LZ8gavDFHA.1496@TK2MSFTNGP14.phx.gbl...
> Oh sorry, missed that. I always just use HttpWebRequest. I'm not even sure
> what the WebClient is for.
>
> I'd definitely go in that direction :)
>
> You'll have to mess with the streams yourself, but that isn't such a big
> deal.
>
> Joe K.
>
> "Raterus" <raterus@hotmail.com> wrote in message
> news:OCx%23SUvDFHA.2756@TK2MSFTNGP15.phx.gbl...
> The WebRequest object has PreAuthenticate, not WebClient. Do you know if
> there is a way to access the underlying WebRequest object that the WebClient
> uses? I didn't see a way to do this. Should I scrap the WebClient and just
> use WebRequest?
>
> Thanks,
> --Michael
>
> "Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com> wrote
> in message news:uouiTFvDFHA.2632@TK2MSFTNGP12.phx.gbl...
>> You can do this by setting PreAuthenticate to True on the WebClient. If
>> the
>> protocol you are using supports it, then that will work. Normally,
>> PreAuthenticate works with Basic auth though. I don't think it works with
>> WIA or Digest (not positive though).
>>
>> Joe K.
>>
>> "Raterus" <raterus@hotmail.com> wrote in message
>> news:Ov37AtuDFHA.2600@TK2MSFTNGP09.phx.gbl...
>> Hello,
>>
>> I'm using the WebClient class to query my webserver to get the contents of
>> a
>> certain page (protected with windows integrated security), I have no
>> problems doing this, but have noticed the WebClient Class does not send
>> the
>> credentials I set until it gets an HTTP 401 return code.
>>
>> We have just created a program to scan the IIS log files for
>> authentication
>> failures. I've noticed in these logs that the WebClient class actually
>> makes two requests of the webserver, it first tries to get the page
>> without
>> sending the credentials, which fails with a 401 error. It tries
>> immediately
>> afterward, sending the credentials, which my webserver responds with the
>> contents.
>>
>> I'd really like to configure the WebClient class to send the credentials
>> immediately, and not wait for the 401. Is this possible to do? It's
>> messing up my program that scans the log files for 401 errors!
>>
>> Thanks,
>> --Michael
>>
>>
>
>



Relevant Pages

  • DownloadFile and Credentials
    ... I am using DownloadFile() on a C# web app to download a file to a ... When I set the WebClient credentials to the DefaultCredentials, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: WebClient and proxy authentication
    ... d> So, if my program uses WebClient to download a file, it will also get ... d> the the un-authenticated error, at which time, the program needs to pop ... d> up the IE/Windows credentials window for the user's credentials. ... CredentialCache myCache = new CredentialCache; ...
    (microsoft.public.dotnet.framework)
  • Re: WebClient + Credentials + HTTP 401 Status Codes
    ... You can do this by setting PreAuthenticate to True on the WebClient. ... but have noticed the WebClient Class does not send the ... credentials I set until it gets an HTTP 401 return code. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • RE: SSO Web Clipping/Page Grafting
    ... You can write your own webpart with the following approach. ... Use SSO to store/retrieve the user's credentials... ... Pass these credentials to a WebClient, and use a WebClient to send a request ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: WebClient + Credentials + HTTP 401 Status Codes
    ... not WebClient. ... but have noticed the WebClient Class does not send ... > credentials I set until it gets an HTTP 401 return code. ... > messing up my program that scans the log files for 401 errors! ...
    (microsoft.public.dotnet.framework.aspnet.security)