java - Javamail NTLM Authentication Failure -


trying connect exchange server using ntlm in javamail. can connect smtp, not imap. can authenticate via os x mail.app application using identical host/username/password, account type = "imap", port 143, ssl=false, authentication=ntlm, domain name="".

the connecting code:

import javax.mail.session; import javax.mail.transport; import javax.mail.store; import java.util.properties;      public class ntlmtest {         public static void main(string[] args) throws exception {             final string host = "example.com";             final string user = "bob";             final string password = "password";              final properties properties = new properties();             session session = session.getdefaultinstance(properties);             session.setdebug(true);              // smtp connect             final transport transport = session.gettransport("smtp");             transport.connect(host, user, password);             system.out.println("smtp connect successful");              // imap connect             final store store = session.getstore("imap");             store.connect(host, user, password);             system.out.println("imap connect successful");          }     } 

the output:

debug: setdebug: javamail version 1.4.3 debug: getprovider() returning javax.mail.provider[transport,smtp,com.sun.mail.smtp.smtptransport,sun microsystems, inc] debug smtp: useehlo true, useauth false debug smtp: trying connect host "example.com", port 25, isssl false 220 server18.example.com esmtp sendmail 8.14.3/8.14.3/debian-5+lenny1; thu, 2 dec 2010 18:05:30 +0100; (no uce/ube) logging access from: xxx.xxx.xxx.xxx debug smtp: connected host "example.com", port: 25  ehlo 192.168.1.107 250-server18.example.com hello c-xxxx [xxx.xxx.xxx.xxx], pleased meet 250-enhancedstatuscodes 250-pipelining 250-8bitmime 250-size 20971520 250-dsn 250-etrn 250-auth digest-md5 cram-md5 login plain 250-starttls 250-deliverby 250 debug smtp: found extension "enhancedstatuscodes", arg "" debug smtp: found extension "pipelining", arg "" debug smtp: found extension "8bitmime", arg "" debug smtp: found extension "size", arg "20971520" debug smtp: found extension "dsn", arg "" debug smtp: found extension "etrn", arg "" debug smtp: found extension "auth", arg "digest-md5 cram-md5 login plain" debug smtp: found extension "starttls", arg "" debug smtp: found extension "deliverby", arg "" debug smtp: found extension "help", arg "" debug smtp: attempt authenticate debug smtp: check mechanisms: login plain digest-md5 ntlm  auth login 334 vxnlcm5hbwu6 ywr2awvzzw5rawvzmdu= 334 ugfzc3dvcmq6 zglja2hvbmluzw== 235 2.0.0 ok authenticated smtp connect successful debug: getprovider() returning javax.mail.provider[store,imap,com.sun.mail.imap.imapstore,sun microsystems, inc] debug: mail.imap.fetchsize: 16384 debug: mail.imap.statuscachetimeout: 1000 debug: mail.imap.appendbuffersize: -1 debug: mail.imap.minidletime: 10 debug: trying connect host "example.com", port 143, isssl false * ok server18.example.com cyrus imap4 v2.1.18-ipv6-debian-2.1.18-5.1 server ready a0 capability * capability imap4 imap4rev1 acl quota literal+ mailbox-referrals namespace uidplus id no_atomic_rename unselect children multiappend sort thread=orderedsubject thread=references idle auth=digest-md5 auth=ntlm auth=cram-md5 annotatemore a0 ok completed imap debug: auth: digest-md5 imap debug: auth: ntlm imap debug: auth: cram-md5 debug: protocolconnect login, host=example.com, user=bob, password=<non-null> debug ntlm: type 1 message: type1message[supplieddomain=,suppliedworkstation=192.168.1.107,flags=0x00000201] debug ntlm: type 1 message length: 45 a1 authenticate ntlm +  tlrmtvntuaabaaaaasiaaaaaaaaaaaaadqanacaaaaaxotiumty4ljeumta3 + tlrmtvntuaacaaaaaaaaadaaaaabigaapdhjra6nzmwaaaaaaaaaaaaaaaaaaaaa tlrmtvntuaadaaaagaayaeaaaaawadaawaaaaaaaaaaaaaaahaacaigaaaaaaboapaaaaaaaaaaaaaaaaqiaalv6miutjkdzsh4izgmvnqnfxjafzind0yjdr4j3oe3lybls0y75uuwbaqaaaaaaanas9yndkssbvbh5v087iuiaaaaaaaaaageazab2agkazqbzaguabgbragkazqbzadaanqaxadkamgauadeanga4ac4amqauadeamaa3aa== a1 no authentication failure exception in thread "main" javax.mail.authenticationfailedexception: authentication failure     @ com.sun.mail.imap.imapstore.protocolconnect(imapstore.java:613)     @ javax.mail.service.connect(service.java:291)     @ javax.mail.service.connect(service.java:172)     @ com.prosc.emailplugin.ntlmtest.main(ntlmtest.java:25) disconnected target vm, address: '127.0.0.1:56125', transport: 'socket'  process finished exit code 1 

i tried wrapping username backslashes, per http://www.oracle.com/technetwork/java/faq-135477.html#exchange-login following error:

exception in thread "main" javax.mail.authenticationfailedexception: 1 time use of plaintext password enable requested mechanism user 

backslashes around username in smtp connect portion cause fail. can't tell if "one time use" error step in right direction or not.

i have noticed - via smtp - ntlm authentication did not work older version of javax.mail (up 1.4.1) works version 1.4.5. , user name specified of form "domain\username". same effect (difference in versions of javax.mail) apply imap.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -