【问题标题】:Is is possible to connect to exchange powershell online using azure-AD app ID/secret?是否可以使用 azure-AD 应用程序 ID/秘密连接到在线交换 powershell?
【发布时间】:2019-10-27 12:33:29
【问题描述】:

是否可以使用已注册的允许 GraphAPI/EWS 访问的 Azure 应用程序 ID/secret 连接到在线交换 powershell?

仅供参考,我知道如何按照 MSFT 网站的指导使用基本身份验证(用户名/密码):https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps

【问题讨论】:

    标签: powershell azure-active-directory exchange-server


    【解决方案1】:

    目前可以使用 Microsoft Graph API 调用交换端点。但它与 Exchange Powershell Online 不同,请参阅此处的交换图 api 文档:https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/office-365-rest-apis-for-mail-calendars-and-contacts

    更多关于如何通过powershell拨打电话的信息,请看这里:https://blogs.technet.microsoft.com/cloudlojik/2018/06/29/connecting-to-microsoft-graph-with-a-native-app-using-powershell/

    您还需要使用有权访问上述交换资源的用户登录。如果您使用无权访问交换资源的应用程序/用户登录,您将收到拒绝访问错误。

    【讨论】:

    • 对不起,我认为这里有一个混淆。让我重新表述我的问题:我在 AzureAD 中有一个注册应用程序,它允许 Graph API/EWS 访问。我基本上是使用appID、secret、租户ID来获取accessToken,然后调用Graph API。我的问题是:是否可以使用该 appID 和 app secret 在线登录交换 powershell?是否必须是工作或学校用户帐户才能在线使用 Exchange Powershell 进行身份验证?
    • 因此,仅使用应用程序 ID 和客户端密码(即客户端凭据流)是不可能的。服务主体需要被授予访问交换服务的明确权限。每个问题:github.com/MicrosoftDocs/azure-docs/issues/10717 如果您对此功能感兴趣,请将其提交到 feedback.azure,产品组将尽快进行调查。另外,如果这回答了您的问题,请记住将其标记为答案。
    【解决方案2】:

    我建议尝试使用已注册的 Azure 应用程序连接 Exchange Online PowerShell 的 EXO V2 预览模块。

    第 1 步:使用 Active Directory 身份验证库 (ADAL) PowerShell 获取 OAuth 访问令牌。

    第二步:创建 PSCredential 对象

    $AppCredential= New-Object System.Management.Automation.PSCredential(<UPN>,<Token>)
    

    Step3:将 PSCredential 传递给 EXO V2 模块。

    Connect-ExchangeOnline -Credential $AppCredential
    

    来源:https://o365reports.com/2020/07/04/modern-auth-and-unattended-scripts-in-exchange-online-powershell-v2/

    【讨论】:

    • 第 2 步中的 UPN 应该是什么,当我使用管理员 UPN 时,由于密码太长而出现错误。此外,将 ClientId 作为 UPN 传递也不起作用。
    猜你喜欢
    • 1970-01-01
    • 2021-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多