Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem while authenticating with on premise Exchange 2013 IMAP4 Server #1351

Closed
zmarkusdev opened this issue Mar 22, 2022 · 3 comments
Closed
Labels
invalid This doesn't seem right

Comments

@zmarkusdev
Copy link

Describe the bug
While connecting with an Exchange 2013 IMAP4 Server we get LOGIN Failed on every attempt since our update to version 3.1.1.
The password and username of the user were checked and are the correct domain user information of the user.

Is there anything wrong with my call to the imap server?

Thanks!

Exception
2022-03-22 09:29:33,478 [54] ERROR IMAP.MailKitImapClient [(null)] - (CheckConnection) - CheckConnection Authentication failed
MailKit.Security.AuthenticationException: LOGIN failed.
at MailKit.Net.Imap.ImapClient.d__103.MoveNext() in D:\src\MailKit\MailKit\Net\Imap\ImapClient.cs:line 1230
--- End of stack trace from previous location where exception was thrown ---

Protocol Logs

Connected to imap://****:143/?starttls=when-available
S: * OK The Microsoft Exchange IMAP4 service is ready.
C: C00000000 CAPABILITY
S: * CAPABILITY IMAP4 IMAP4rev1 LOGINDISABLED STARTTLS UIDPLUS MOVE ID CHILDREN IDLE NAMESPACE LITERAL+
S: C00000000 OK CAPABILITY completed.
C: C00000001 STARTTLS
S: C00000001 OK Begin TLS negotiation now.
C: C00000002 CAPABILITY
S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=NTLM AUTH=GSSAPI UIDPLUS MOVE ID CHILDREN IDLE NAMESPACE LITERAL+
S: C00000002 OK CAPABILITY completed.
C: C00000003 AUTHENTICATE NTLM
S: +
C: ********
S: + TlRMTV.....
C: ********
S: C00000003 NO AUTHENTICATE failed.
C: C00000004 AUTHENTICATE PLAIN
S: +
C: ********
S: C00000004 NO AUTHENTICATE failed.
C: C00000005 LOGIN ******** ********
S: C00000005 NO LOGIN failed.
C: C00000006 LOGOUT
S: * BYE Microsoft Exchange Server 2013 IMAP4 server signing off.
S: C00000006 OK LOGOUT completed.

@jstedfast
Copy link
Owner

I could be wrong as I haven't done any thorough testing of this theory, but it seems that once NTLM authentication is attempted with Exchange, if that fails, it will reject any other SASL mechanism used.

Try using https://www.myget.org/feed/mimekit/package/nuget/MailKit to see if that solves the issue. There's been some NTLM fixes in that build.

Alternatively, try disabling NTLM:

client.AuthenticationMechanisms.Remove ("NTLM");

My goal is to fix NTLM to always work correctly which is why 3.0 has a complete rewrite that I wrote based on the official specs whereas 2.x and older had an implementation I borrowed from Mono which was based on reverse engineering. That said, there was a bug discovered by the eM Client guys in my new NTLM implementation (issue #1340) that I recently fixed but haven't yet published a release with that fix.

If you end up testing with the latest build and it works for you, let me know, and I'll try to expedite a release.

@jstedfast
Copy link
Owner

Oh, you might need MimeKit from that myget source as well - I think MailKit might make use of some of the new optimization APIs that are in that MimeKit.

@jstedfast
Copy link
Owner

@zmarkusdev Any update on this? Did my suggestion(s) work?

@jstedfast jstedfast added the invalid This doesn't seem right label Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants