Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A36677645 for ; Fri, 11 Nov 2011 08:17:50 +0000 (UTC) Received: (qmail 65651 invoked by uid 500); 11 Nov 2011 08:17:50 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 65423 invoked by uid 500); 11 Nov 2011 08:17:48 -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 65413 invoked by uid 99); 11 Nov 2011 08:17:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Nov 2011 08:17:48 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.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; Fri, 11 Nov 2011 08:17:42 +0000 Received: by ok2cons2.nine.ch (Postfix, from userid 1000) id 9F6DB245E4C4; Fri, 11 Nov 2011 09:17:21 +0100 (CET) Date: Fri, 11 Nov 2011 09:17:21 +0100 From: Oleg Kalnichevski To: HttpClient User Discussion Subject: Re: Issues accessing NTLM server using HTTPClient 4.1 Message-ID: <20111111081721.GA726@ok2cons2.nine.ch> Mail-Followup-To: HttpClient User Discussion References: <1303056882.13768.8.camel@ubuntu> <32819071.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <32819071.post@talk.nabble.com> User-Agent: Mutt/1.5.18 (2008-05-17) On Thu, Nov 10, 2011 at 06:40:59AM -0800, Srivatsan wrote: > > Have a similar issue. With the code below - authentication is unsuccessful > when using the credentials of a local user. By local user, the domain name / > realm is the host itself. However, authentication is successful with the > same credentials when accessed from browser. > > DefaultHttpClient httpclient = new DefaultHttpClient(); > List authpref = new ArrayList(); > authpref.add(AuthPolicy.NTLM); > httpclient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, > authpref); > NTCredentials creds = new NTCredentials("uid", "pwd", "ip", "domain"); > httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds); > HttpHost target = new HttpHost(, 80, "http"); > // Make sure the same context is used to execute logically related > requests > HttpContext localContext = new BasicHttpContext(); > // Execute a cheap method first. This will trigger NTLM authentication > HttpGet httpget = new HttpGet(); > HttpResponse response; > try { > response = httpclient.execute(target, httpget, localContext); > System.out.println("Status Code:" + > response1.getStatusLine().getStatusCode()); > BufferedReader isr = new BufferedReader (new > InputStreamReader(response.getEntity().getContent())); > while (isr.readLine() != null) { > System.out.println("Content is: ********" + isr.readLine()); > } > HttpEntity entity = response1.getEntity(); > EntityUtils.consume(entity); > } catch (ClientProtocolException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > Added the HTTP wire log. > http://old.nabble.com/file/p32819071/localuser-nabble.txt > localuser-nabble.txt > > Any pointers, please? > I see nothing unusual in the HTTP session log. The three-way NTLM message exchange seems normal. You can try using CIFS as an alternative NTLN engine and see if that makes any difference [1]. If that does not help, there must be something wrong with the credentials. Oleg [1] http://hc.apache.org/httpcomponents-client-ga/ntlm.html --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org