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

Office365 IMAP - Inbox returning null when no mailbox permissions #1135

Closed
RichardD2 opened this issue Jan 13, 2021 · 1 comment
Closed

Office365 IMAP - Inbox returning null when no mailbox permissions #1135

RichardD2 opened this issue Jan 13, 2021 · 1 comment
Labels
compatibility Compatibility with existing software enhancement New feature or request

Comments

@RichardD2
Copy link

RichardD2 commented Jan 13, 2021

Description
After connecting and authenticating an ImapClient pointing to a different mailbox, the Inbox property can return null.

The protocol log shows "User is authenticated but not connected".

After signing in to Office365 with the same credentials, it appears the problem occurs when the user has no permission to access the mailbox.

Platform (please complete the following information):

  • OS: Windows Server 2016 (1607)
  • .NET Framework: .NET 4.8
  • MailKit Version: 2.10.1

To Reproduce

using var client = new ImapClient(new ProtocolLogger("imap.log"));
await client.ConnectAsync("outlook.office365.com", 993, SecureSocketOptions.Auto, cancellationToken);
await client.AuthenticateAsync(new NetworkCredential(@"user@domain.com\mailbox", "password"), cancellationToken);
if (client.Inbox is null) throw new InvalidOperationException("Inbox not found!");

Expected behavior
I'm not too sure here. Obviously it would be better if the authenticate call would fail with an exception, since the user has no access to the mailbox. But it appears that the login completes OK.

Perhaps the Inbox property should throw an exception? I'm assuming the NAMESPACE command is issued when this property is accessed.

Protocol log

Connected to imaps://outlook.office365.com:993/
S: * OK The Microsoft Exchange IMAP4 service is ready. [QQBNAD...]
C: J00000000 CAPABILITY
S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
S: J00000000 OK CAPABILITY completed.
C: J00000001 AUTHENTICATE PLAIN AHVzZXJAZG9tYWluLmNvbVxtYWlsYm94AHBhc3N3b3Jk
S: J00000001 NO AUTHENTICATE failed.
C: J00000002 LOGIN "user@domain.com\\mailbox" password
S: J00000002 OK LOGIN completed.
C: J00000003 CAPABILITY
S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CLIENTACCESSRULES CLIENTNETWORKPRESENCELOCATION BACKENDAUTHENTICATE CHILDREN IDLE NAMESPACE LITERAL+
S: J00000003 OK CAPABILITY completed.
C: J00000004 NAMESPACE
S: J00000004 BAD User is authenticated but not connected.
C: J00000005 LIST "" "INBOX"
S: J00000005 BAD User is authenticated but not connected.
S: * BYE Connection closed. 14

(Credentials obfuscated on both AUTHENTICATE and LOGIN lines.)

@jstedfast
Copy link
Owner

Oh, interesting... thanks for the bug report. I'll try to look into this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility with existing software enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants