Authenticate() public method

Authenticates the client to the server using the best supported SASL mechanism.
public Authenticate ( NetworkCredential credentials, SaslMechanics mechanic = (SaslMechanics)0x0000 ) : bool
credentials System.Net.NetworkCredential The user credentials.
mechanic SaslMechanics The SASL mechanism to use. This param is optional and can be left blank (0x0000), if done so, the best fitting mechanism will be chosen automatically.
return bool
コード例 #1
0
        public static ImapClient CreateClientByAccount(Account account)
        {
            try
            {
                var client = new ImapClient { Security = account.Security };
                //client.ManualSaslAuthenticationRequired += (sender, e) => AuthenticateManually(e, account);
                var port = client.Security == SecurityPolicies.Explicit ? ImapPorts.Ssl : ImapPorts.Default;
                client.Connect(account.Host, port);
                //Thread.Sleep(100);
                client.Authenticate(account.Credential, SaslMechanics.Login);
                //Thread.Sleep(500);

                return client;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
コード例 #2
0
ファイル: MailProvider.cs プロジェクト: pravse/CommSample
        public ImapClient InitClient(ImapAccountInfo account)
        {
            Debug.Assert(null != account);

            ImapClient imapClient = new Crystalbyte.Equinox.Imap.ImapClient();
            imapClient.Security = SecurityPolicies.Explicit;

            imapClient.Connect(this.Host, this.Port);

            if ((null != account.UserName) && (null != account.UserPwd))
            {
                // doesn't need OAuth --- try regular LOGIN
                imapClient.Authenticate(account.UserName, account.UserPwd, SaslMechanics.Login);
            }
            else
            {
                imapClient.ManualSaslAuthenticationRequired += (sender, e) => this.AuthHandler(e.Client, e.UserCredentials, account);
                imapClient.Authenticate(account.UserName, account.UserPwd);
            }
            return imapClient;
        }
コード例 #3
0
ファイル: ApplicationForm.cs プロジェクト: pravse/CommSample
 private ImapClient CreateClientByAccount(Account account)
 {
     try {
         var client = new ImapClient {Security = account.Security};
         client.ManualSaslAuthenticationRequired += (sender, e) => AuthenticateManually(e, account);
         var port = client.Security == SecurityPolicies.Explicit ? ImapPorts.Ssl : ImapPorts.Default;
         client.Connect(account.Host, port);
         client.Authenticate(account.Credential);
         return client;
     }
     catch (Exception ex) {
         LogSafely(ex.Message);
         throw;
     }
 }