Connect then Login doesn't enter proper State in POP3/IMAP

Last post 12-02-2010, 4:23 PM by aspose.notifier. 9 replies.
Sort Posts: Previous Next
  •  10-05-2010, 12:10 PM 262031

    Connect then Login doesn't enter proper State in POP3/IMAP

    I am trying to separate my Connect/Login calls using both the Pop3Client and ImapClient classes to help make my error reporting more specific.

    In passing bad username/password data, calling "client.Connect(true);" will throw a Pop3Exception/ImapException.

    But, breaking the connection and login into two separate calls, I do not receive the Exception, and I instead get an error later in my code:

        using (var client = new Pop3Client("pop.gmail.com", 995, "baduser", "badpw"))
    //    using (var client = new ImapClient("imap.gmail.com", 993, "baduser", "badpw"))
        {
            client.SecurityMode = Pop3SslSecurityMode.Implicit; // or ImapSslSecurityMode.Implicit;
            client.EnableSsl = true;
            try
            {
                client.Connect(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Connection Error: " + ex);
                return;
            }
            try
            {
                client.Username = username;
                client.Password = password;
                client.Login();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Login Error: " + ex);
                return;
            }

            // Should now be in the TRANSACTION/Authenticated State
            var nummessages = client.GetMessageCount(); // Throws Pop3Exception: "STAT failed:-ERR bad command"
            client.Quit();
    /* For IMAP
            client.SelectFolder(ImapFolderInfo.InBox); // Throws ImapException
            client.Disconnect();
    */
        }

    I don't set the Username/Password fields until after the "client.Connect(false);", because it seems like if I do specify them, the client tries to initiate the login anyway.

    This approach also fails when passing legitimate login credentials as well.
     
  •  10-06-2010, 2:16 PM 262230 in reply to 262031

    Re: Connect then Login doesn't enter proper State in POP3/IMAP .NET

    Attachment: Present (inaccessible)
    Hi,

    Thank you for inquiry.

    Could you please try with the latest version of Aspose.Network for .NET 5.7? I could not reproduce the exceptions mentioned in the comments in above code.

    By providing a valid user/pwd, there is no exception in calling first Connect(false) and Login() later.

    But, by providing a bad user/pwd
    1. exception is thrown on Connect(false) for IMAP
    2. for POP3, Connect(false) works without exception, but Login() throws the login error exception.
    Please find the attached sample project that I used for testing.

    Best Regards,
    Saqib Razzaq
    Support Developer, Aspose Sialkot Team
    http://www.aspose.com
    Your File Format Experts
     
  •  10-06-2010, 4:59 PM 262260 in reply to 262230

    Re: Connect then Login doesn't enter proper State in POP3/IMAP

    saqib.razzaq:
    Could you please try with the latest version of Aspose.Network for .NET 5.7? I could not reproduce the exceptions mentioned in the comments in above code.

    By providing a valid user/pwd, there is no exception in calling first Connect(false) and Login() later.

    But, by providing a bad user/pwd
    1. exception is thrown on Connect(false) for IMAP
    2. for POP3, Connect(false) works without exception, but Login() throws the login error exception.


    After upgrading to 5.7, you're right, the POP3 Connect, then Login works as expected.  But, the IMAP version still does not handle this correctly.

    Also, with both, I have to specify the username/password in the constructor, rather than setting the properties after the Connect call.
     
  •  10-07-2010, 6:48 AM 262359 in reply to 262260

    Re: Connect then Login doesn't enter proper State in POP3/IMAP .NET

    Attachment: Present (inaccessible)
    jay_bp:

    After upgrading to 5.7, you're right, the POP3 Connect, then Login works as expected.  But, the IMAP version still does not handle this correctly.
    Yes, the IMAP throws exception on Connect(false) method, when a bad user/pwd is specified.

    jay_bp:

    Also, with both, I have to specify the username/password in the constructor, rather than setting the properties after the Connect call.
    The sample which I attached is based on your example. It
    1. Calls Connect(false)
    2. Sets user and password
    3. Calls Login()
    All 3 steps worked fine at my end with correct user/pwd, without any exception.

    I have also attached a screenshot of my debug session in VS.

    Best Regards,
    Saqib Razzaq
    Support Developer, Aspose Sialkot Team
    http://www.aspose.com
    Your File Format Experts
     
  •  10-07-2010, 7:51 PM 262458 in reply to 262359

    Re: Connect then Login doesn't enter proper State in POP3/IMAP

    saqib.razzaq:
    jay_bp:

    Also, with both, I have to specify the username/password in the constructor, rather than setting the properties after the Connect call.
    The sample which I attached is based on your example. It
    1. Calls Connect(false)
    2. Sets user and password
    3. Calls Login()
    All 3 steps worked fine at my end with correct user/pwd, without any exception.

    If we remove the username/password from the constructor, then the first client call after the .Login() call throws an exception:
        using (var client = new Pop3Client(host, port)) // No username/password here
        {
            client.SecurityMode = Pop3SslSecurityMode.Implicit;
            client.EnableSsl = true;
            try
            {
                client.Connect(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Connection Error: " + ex);
                return;
            }
            try
            {
                client.Username = username;
                client.Password = password;
                client.Login();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Login Error: " + ex);
                return;
            }

            // The server must implement this command
            Console.WriteLine("Connection Success: {0} messages", client.GetMessageCount()); //This throws an exception

     
  •  10-08-2010, 5:42 PM 262665 in reply to 262458

    Re: Connect then Login doesn't enter proper State in POP3/IMAP

    Hi,

    I have reproduced the issue now. Sorry for overlooking previously. I have also logged these issues in our issue tracking system (ID: 20655 and 20656) for both POP3 and IMAP. We will look into these and will get back to you as soon we have any solution or other feedback.

    Best Regards,
    Saqib Razzaq
    Support Developer, Aspose Sialkot Team
    http://www.aspose.com
    Your File Format Experts
     
  •  10-21-2010, 6:53 AM 264910 in reply to 262031

    Re: Connect then Login doesn't enter proper State in POP3/IMAP

    The issues you have found earlier (filed as 20656;20655) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
     
  •  11-02-2010, 5:58 PM 267036 in reply to 264910

    Re: Connect then Login doesn't enter proper State in POP3/IMAP

    Thanks for the updates.

    It's a problem around which we can work, but it seems like in the ImapClient class, calling "client.Connect(false);" will behave differently depending on setting a username/password before calling it or afterward.

    The following works how I would expect:
    client.Connect(false);
    client.Username = "BadUser";
    client.Password = "BadPass";
    client.Login(); // Throws ImapException, which we would expect

    But, if I change the order, it appears that the "Connect(false)" call tries to validate the credentials:
    client.Username = "BadUser";
    client.Password = "BadPass";
    client.Connect(false); // Throws ImapException here
    client.Login(); // We would expect the ImapException here

     
  •  11-03-2010, 11:25 AM 267185 in reply to 267036

    Re: Connect then Login doesn't enter proper State in POP3/IMAP .NET

    Hi,

    Thanks for posting the details. We will check this issue and will inform you when it will be resolved. The Issue ID is 21264.

    Best Regards,
    Saqib Razzaq
    Support Developer, Aspose Sialkot Team
    http://www.aspose.com
    Your File Format Experts
     
  •  12-02-2010, 4:23 PM 271687 in reply to 262031

    Re: Connect then Login doesn't enter proper State in POP3/IMAP

    The issues you have found earlier (filed as 21264) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
     
View as RSS news feed in XML