예제 #1
0
        protected void btnDisableYes_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(hfDisableUserPrincipalName.Value))
            {
                ExchCmds powershell = null;

                try
                {
                    powershell = new ExchCmds(Config.ExchangeURI, Config.Username, Config.Password, Config.ExchangeConnectionType, Config.PrimaryDC);

                    // Disable the mailbox
                    powershell.Disable_Mailbox(hfDisableUserPrincipalName.Value);

                    // Delete from SQL
                    SQLMailboxes.DisableMailbox(hfDisableUserPrincipalName.Value, CPContext.SelectedCompanyCode);

                    // Notify
                    notification1.SetMessage(controls.notification.MessageType.Success, Resources.LocalizedText.NotificationSuccessMailboxDisable + hfDisableUserPrincipalName.Value);

                    // Wipe
                    hfDisableUserPrincipalName.Value = null;
                }
                catch (Exception ex)
                {
                    notification1.SetMessage(controls.notification.MessageType.Error, ex.Message);
                }
                finally
                {
                    if (powershell != null)
                        powershell.Dispose();

                    // Go back to mailbox user view
                    GetMailboxUsers();
                }
            }
        }