# 如何設定 Office 365 與 Outlook 桌面應用程式使用 MFA 多因子認證

最近由於微軟開始要求所有合作夥伴都要通過帳號密碼的基本[安全性需求](https://learn.microsoft.com/zh-tw/partner-center/partner-security-requirements)，結果我在做完一切設定之後，我在 Windows 10 的 Outlook 桌面應用程式就無法登入了。雖然 Outlook 2013 之後都有支援 MFA 多因子認證，但我研究一段時間後才發現，原來還要透過 Exchange Online PowerShell 對 Office 365 的組織進行設定，才能真正透過 MFA 登入使用 Outlook 桌面應用程式。但設定過程一堆地雷，花了我幾個小時才搞定，卡關的朋友請繼續看下去。

### 強制執行多重要素驗證

因為 Office 365 的背後，通通是使用 Azure AD 作為帳號的身分識別管理，這部分只要透過設定 [Azure AD 安全性預設值](https://learn.microsoft.com/zh-tw/partner-center/partner-security-requirements) 就可以強制管理者一定要使用多重因素驗證。

> 請注意：這裡的 **MFA** (Multi-Factor Authentication) 在網路上有很多種不同的中文翻譯，所以你可能會看到像是「多因子認證」、「多重要素驗證」或「多因素驗證」都有，以下文章我會通通以 **MFA** 來表示，以免造成閱讀或理解上的困難。

啟用步驟如下：

1.  登入 Azure 入口網站的 [Azure Active Directory](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview) 頁面
    
    ![image](https://stwillblogassets.blob.core.windows.net/files/images/external/user-images.githubusercontent.com/aee5db9d962035d4464b-71540741-a3960e00-2989-11ea-8efd-e62dddfdd952.png)
    
    > 請務必用 **Global Admins** (**全域管理員**) 身分登入。
    
2.  點擊左側的 **屬性** (**Properties**)，然後捲動到頁面最下方，先將管理者自己加入**管理者群組**，然後設定 **管理安全性預設值** (**Manage Security defaults**)：
    
    ![image](https://stwillblogassets.blob.core.windows.net/files/images/external/user-images.githubusercontent.com/2b815815f91d84d8e099-71540737-87926c80-2989-11ea-82be-b0d7ff66b8ad.png)
    
3.  接著設定 **啟用安全性預設值** (**Enable Security defaults**) 為 **是** (**Yes**)
    
    ![image](https://stwillblogassets.blob.core.windows.net/files/images/external/user-images.githubusercontent.com/68fe641960a329f40911-71540779-17381b00-298a-11ea-9172-6efc9a75b8fd.png)
    

啟用之後，整體組織的安全性會大幅提升，但是也會有以下注意事項：

-   **安全性預設值** (Security defaults) 即將取代 **基準原則** (baseline policies)。
-   已採用**基準原則**的**合作夥伴**必須轉換成**安全性預設值**。
-   微軟預計會在 2020 年 2 月底淘汰**基準原則**。
-   使用安全性預設值時，將會一次啟用所有原則。
-   如需詳細資訊，請閱讀[針對貴組織啟用 Multi-Factor Authentication](https://learn.microsoft.com/azure/active-directory/authentication/concept-mfa-get-started) 和 [Azure Active Directory 安全性預設值](https://learn.microsoft.com/azure/active-directory/conditional-access/concept-conditional-access-security-defaults)。

簡言之，所有 Office 365 用戶，在未來 14 天以內，都需要啟用 MFA 驗證，否則將會無法登入。但如果你是系統管理員，則必須立刻設定 MFA 認證！

### 啟用每位使用者的 MFA 功能

請用 Office 365 管理者登入以下網址，即可設定每位使用者是否可以使用 MFA 多重要素驗證：

-   [https://go.microsoft.com/fwlink/?LinkId=279980](https://go.microsoft.com/fwlink/?LinkId=279980)

相關連結

-   [如何為 Office 365 使用者設定多重要素驗證 (MFA)](https://learn.microsoft.com/zh-tw/office365/admin/security-and-compliance/set-up-multi-factor-authentication?view=o365-worldwide)
-   [如何要求使用者使用雙步驟驗證](https://learn.microsoft.com/zh-tw/azure/active-directory/authentication/howto-mfa-userstates)

### 設定 **應用程式密碼** / 啟用 **新式驗證** (**Modern authentication**) 選項

當啟用 MFA 之後，要讓**桌面應用程式**通過 MFA 驗證的方法只有兩種：

1.  使用**應用程式密碼** (App password)
    
    基本上，不支援 MFA 驗證的舊式應用程式，都要透過建立應用程式密碼才能登入成功。
    
    建立應用程式密碼的步驟如下：
    
    1.  進入 [Microsoft 帳戶 | Security](https://account.microsoft.com/security/) 頁面
    2.  點擊 **更多安全性選項** 進入，並找到 **應用程式密碼** 區塊的 [建立新的應用程式密碼](https://account.live.com/proofs/AppPassword)
    
    > 其實直接進入 [建立新的應用程式密碼](https://account.live.com/proofs/AppPassword) 網頁就會立刻得到一組密碼，重新整理就會得到新的一組。
    
    > 官方文件 [管理適用於雙步驟驗證的應用程式密碼](https://learn.microsoft.com/zh-tw/azure/active-directory/user-help/multi-factor-authentication-end-user-app-passwords#create-and-delete-app-passwords-from-the-additional-security-verification-page) 所說的 **app passwords** 頁籤我完全找不到，真的浪費生命很多，唉！
    
2.  使用**新式驗證** (Modern authentication)
    
    對於支援新式驗證的應用程式 (例如: Outlook 2013 之後的版本)，則不用特別設定就可以登入。
    
    由於我才剛把自己的帳號設定好 MFA 驗證，第一時間發現的問題就是 Outlook 桌面應用程式完全無法登入了！
    
    官方文件雖然有提供 [為組織啟用多重要素驗證](https://learn.microsoft.com/zh-tw/office365/admin/security-and-compliance/set-up-multi-factor-authentication?view=o365-worldwide) 的說明，但是在我公司的 Office 365 管理中心就完全找不到 **新式驗證** (**Modern authentication**) 的選項。最後被迫要使用 PowerShell 來進行設定，但是以往所知道的登入方式，在啟用 MFA 之後，就無法再用以前的方式透過 PowerShell 登入，你必須參考 [使用多重要素驗證連線至 Exchange Online PowerShell](https://learn.microsoft.com/zh-tw/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?redirectedfrom=MSDN&view=exchange-ps) 文件的步驟，才能開啟 PowerShell 連接 Exchange Online 服務。
    
    但是[使用多重要素驗證連線至 Exchange Online PowerShell](https://learn.microsoft.com/zh-tw/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?redirectedfrom=MSDN&view=exchange-ps)必須用 **Internet Explorer** (IE!!) 進入 **Exchange 系統管理中心**，點擊左側的「混合」(Hybrid)，點擊第二個【設定】按鈕，並透過 ClickOnce 自動安裝一個軟體，然後他就會自動開啟 PowerShell 視窗：
    
    ![image](https://stwillblogassets.blob.core.windows.net/files/images/external/user-images.githubusercontent.com/19e27aa0259494e94aae-71541667-98e27580-2997-11ea-8a0e-5b11630eedd5.png)
    
    接著才可以參考 [使用 MFA 連線至 Exchange Online PowerShell](https://learn.microsoft.com/zh-tw/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?redirectedfrom=MSDN&view=exchange-ps#connect-to-exchange-online-powershell-by-using-mfa) 文件說明來連線：
    
    ```powershell
    Connect-EXOPSSession -UserPrincipalName chris@contoso.com
    ```
    
    > 要用 IE 才能執行 ClickOnce 啊啊啊啊啊~~~~~
    
    登入之後，才能用以下命令啟用新式驗證：
    
    ```powershell
    Set-OrganizationConfig -OAuth2ClientProfileEnabled $true
    ```
    
    > 參見: [針對 Outlook 2013 或更新版本的用戶端連線，在 Exchange Online 中啟用或停用新式驗證](https://learn.microsoft.com/zh-tw/exchange/clients-and-mobile-in-exchange-online/enable-or-disable-modern-authentication-in-exchange-online#enable-or-disable-modern-authentication-in-exchange-online-for-client-connections-in-outlook-2013-or-later)
    

### 幫助使用者設定 MFA 多重要素驗證

基本上，要啟用 MFA 驗證還蠻直覺的，當你登入時就會問你要不要設定 MFA 驗證。

如果已經登入，可以透過這個連結設定 MFA 多重要素驗證: [https://aka.ms/MFASetup](https://aka.ms/MFASetup)

-   你可以在這裡設定多種驗證方式，我大多都是設定手機驗證，但你也可以設定簡訊驗證，記得輸入手機號碼。

> 這部分請參考 [設定 Office 365 的雙步驟驗證](https://support.office.com/zh-tw/article/%e8%a8%ad%e5%ae%9a-office-365-%e7%9a%84%e9%9b%99%e6%ad%a5%e9%a9%9f%e9%a9%97%e8%ad%89-ace1d096-61e5-449b-a875-58eb3d74de14?WT.mc_id=365AdminCSH&ui=zh-TW&rs=zh-TW&ad=TW) ( [Set up 2-step verification for Office 365](https://support.office.com/en-us/article/Set-up-2-step-verification-for-Office-365-ace1d096-61e5-449b-a875-58eb3d74de14?WT.mc_id=365AdminCSH) ) 進行設定即可。

### 結語

Office 365 每隔一兩年就會改一次介面，文件通常不會即時更新，所以會有很多管理選項找不到，或是錯誤的描述。如果是談觀念，通常改變不大，但是操作方式、網址一直改變，對管理者來說真的非常困擾！

如果不急，下次遇到設定困難，是可以直接建立一個服務要求，微軟至少客服人員的態度都不錯，有任何問題都會幫你解決。

### 常用連結

-   [變更 Office 365 使用者設定](https://account.activedirectory.windowsazure.com/r/#/profile)
-   [變更 Office 365 使用者密碼](https://account.activedirectory.windowsazure.com/ChangePassword.aspx)
-   [Microsoft 帳戶 - 安全性設定](https://account.microsoft.com/security/)
-   [設定使用者 MFA 多重要素驗證](https://aka.ms/MFASetup)
-   [Azure AD 條件式存取 - 原則](https://portal.azure.com/?l=zh-hant.zh-tw#blade/Microsoft_AAD_IAM/ConditionalAccessBlade/Policies)
-   [建立新的應用程式密碼](https://account.live.com/proofs/AppPassword)

### 相關連結

-   [Partner security requirements - Partner Center | Microsoft Docs](https://learn.microsoft.com/en-us/partner-center/partner-security-requirements)
-   [Enable modern authentication in Exchange Online](https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/enable-or-disable-modern-authentication-in-exchange-online)
-   [Configure Azure Multi-Factor Authentication settings](https://learn.microsoft.com/en-us/azure/active-directory/authentication/howto-mfa-mfasettings)
-   [What are security defaults?](https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/concept-fundamentals-security-defaults)
-   [Enable Multi-Factor Authentication for your organization](https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/concept-fundamentals-mfa-get-started)
    -   [How to require two-step verification for a user](https://learn.microsoft.com/en-us/azure/active-directory/authentication/howto-mfa-userstates)
-   [How to manage app passwords - Azure Active Directory | Microsoft Docs](https://learn.microsoft.com/en-us/azure/active-directory/user-help/multi-factor-authentication-end-user-app-passwords)
-   [After enabling MFA on Office 365 I can't login to Outlook even - Microsoft Community](https://answers.microsoft.com/en-us/msoffice/forum/all/after-enabling-mfa-on-office-365-i-cant-login-to/6ee750bf-c0f5-44d0-a1a9-d31a91907284)
