Return-Path: Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: (qmail 46023 invoked from network); 17 Apr 2011 16:15:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Apr 2011 16:15:17 -0000 Received: (qmail 81399 invoked by uid 500); 17 Apr 2011 16:15:16 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 81366 invoked by uid 500); 17 Apr 2011 16:15:16 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 81358 invoked by uid 99); 17 Apr 2011 16:15:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Apr 2011 16:15:16 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [92.42.190.144] (HELO ok2cons2.nine.ch) (92.42.190.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Apr 2011 16:15:07 +0000 Received: from [192.168.1.101] (77-57-197-206.dclient.hispeed.ch [77.57.197.206]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ok2cons2.nine.ch (Postfix) with ESMTPSA id B1F9A245E401 for ; Sun, 17 Apr 2011 18:14:47 +0200 (CEST) Subject: Re: Issues accessing NTLM server using HTTPClient 4.1 From: Oleg Kalnichevski To: HttpClient User Discussion In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Sun, 17 Apr 2011 18:14:42 +0200 Message-ID: <1303056882.13768.8.camel@ubuntu> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Sun, 2011-04-17 at 20:03 +0530, Dilshan Edirisuriya wrote: > Hi , > > I have a web page that need to access with NTLM authentication on my local > machine and i can see the expected behavior with Web browsers. But when I > try to access same page using HTTPClient 4.1 I'm getting following > exception. > > > Apr 17, 2011 7:18:23 PM > org.apache.http.client.protocol.RequestTargetAuthentication process > SEVERE: Authentication error: Invalid name provided (Mechanism level: Could > not load configuration file C:\Windows\krb5.ini (The system cannot find the > file specified)) > Status :: HTTP/1.1 401 Unauthorized > > Dilshan HttpClient chooses SPNEGO/kerberos auth scheme over NTLM per default in case the server supports both, as SPNEGO/kerberos is considered somewhat more secure than NTLM. You can alter the order of preferred auth schemes by using 'http.auth.target-scheme-pref' or 'http.auth.proxy-scheme-pref' parameters: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html#d4e869 Just a general remark: when troubleshooting problems with HttpClient a wire / context log of the HTTP session exhibiting the problem helps a great deal. Oleg > This is my sample code and it exactly same as example given in here > http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html#ntlm > > DefaultHttpClient httpclient = new DefaultHttpClient(); > > NTCredentials creds = new NTCredentials("user", "pwd", "machin-name", > "machin-name"); > httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds); > > Host target = new HttpHost("localhost", 9090, "http"); > HttpContext localContext = new BasicHttpContext(); > > // Execute a cheap method first. This will trigger NTLM authentication > HttpGet httpget = new HttpGet("/hello1"); > HttpResponse response = httpclient.execute(target, httpget, > localContext); > HttpEntity entity = response.getEntity(); > System.out.println(" Status :: "+ response.getStatusLine()); > > > Further analyzing i found there is no 'Authorization:" header in outgoing > messages where this header is available with browser access. Please note > that I used same name/password/Domain for browser access too. > > Appreciate for any help to resolve this ? > > Thank you , > > Dilshan --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org