针对 Office 365 的 Exchange Web 服务身份验证问题

发布于 2024-11-16 20:22:46 字数 2064 浏览 2 评论 0原文

我正在开发我的第一个 Orchard CMS 模块,该模块将与 Exchange Server 交互,以便向 Orchard 添加 Exchange 任务功能(主要是提供个人任务的 Web 管理)。不幸的是,我认为 Office 365 不支持所需的身份验证类型。此Microsoft 文档概述了有关以下内容的一些说明:设置具有模拟权限的服务帐户,以便使用 Exchange Web 服务。

不幸的是,我需要能够运行“New-ManagementRoleAssignment”cmdlet,才能分配模拟权限。我在尝试此 cmdlet 时收到的错误是:

The term 'New-ManagementRoleAssignment' is not recognized as the name of a cmdlet, function, script file, or operable program.

按照前面的 URL 中的说明,我已正确连接。我读到的所有内容都表明该命令应该可用。我错过了什么吗?我正在使用 Office 365 企业版,以防万一。我用于通过 PowerShell 登录的帐户是我的全局管理员帐户。

任何帮助和/或见解将非常感激!我也得到了 Microsoft 的支持,所以我会发布从他们那里得到的任何信息。

维托

[编辑] 我决定为那些拥有 Exchange Server 并有兴趣尝试此操作的人添加一些代码。您必须下载 Exchange Web Services dll,才能使用命名空间 Microsoft.Exchange.WebServices。

using Microsoft.Exchange.WebServices.Data;
using Microsoft.Exchange.WebServices.Autodiscover;

private static ExchangeService _service;
private static void ConnectToExchangeService()
{
    _service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
    _service.TraceEnabled = true;
    _service.Credentials = new System.Net.NetworkCredential("[email protected]", "password");

    AutodiscoverService ads = new AutodiscoverService();
    ads.EnableScpLookup = false;
    ads.RedirectionUrlValidationCallback = delegate { return true; };
    GetUserSettingsResponse grResp = ads.GetUserSettings("[email protected]", UserSettingName.ExternalEwsUrl);
    Uri casURI = new Uri(grResp.Settings[UserSettingName.ExternalEwsUrl].ToString());
    _service.Url = casURI;

    ControllerContext ctx = new ControllerContext();
    ctx.HttpContext.Response.Write("Server Info: " + _service.ServerInfo.VersionString);
    ctx.HttpContext.Response.Flush();
}

I'm in the process of developing my first Orchard CMS module, which will interface with Exchange Server for the purpose of adding Exchange Task functionality to Orchard (basically providing web management of personal Tasks). Unfortunately, I don't think Office 365 supports the type of authentication required. This Microsoft document outlines some instructions on setting up a service account with impersonation rights, in order to use Exchange Web Services.

Unfortunately, I need to be able to run the "New-ManagementRoleAssignment" cmdlet, in order to assign the impersonation rights. The error I'm receiving when attempting this cmdlet is:

The term 'New-ManagementRoleAssignment' is not recognized as the name of a cmdlet, function, script file, or operable program.

I'm definetely connected properly, as instructed in that previous URL. Everything I'm reading suggests that this command should be available. Am I missing something? I'm using the Enterprise version of Office 365, in case that matters. The account that I'm using to log in with PowerShell is my global admin account.

Any help and/or insight would be very much appreciated! I have a support in with Microsoft as well, so I'll post anything I get back from them.

Vito

[EDIT]
I've decided to add some code, for those who have an Exchange Server and are interested in trying this out. You'll have to download the Exchange Web Services dll, in order to make use of the namespace Microsoft.Exchange.WebServices.

using Microsoft.Exchange.WebServices.Data;
using Microsoft.Exchange.WebServices.Autodiscover;

private static ExchangeService _service;
private static void ConnectToExchangeService()
{
    _service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
    _service.TraceEnabled = true;
    _service.Credentials = new System.Net.NetworkCredential("[email protected]", "password");

    AutodiscoverService ads = new AutodiscoverService();
    ads.EnableScpLookup = false;
    ads.RedirectionUrlValidationCallback = delegate { return true; };
    GetUserSettingsResponse grResp = ads.GetUserSettings("[email protected]", UserSettingName.ExternalEwsUrl);
    Uri casURI = new Uri(grResp.Settings[UserSettingName.ExternalEwsUrl].ToString());
    _service.Url = casURI;

    ControllerContext ctx = new ControllerContext();
    ctx.HttpContext.Response.Write("Server Info: " + _service.ServerInfo.VersionString);
    ctx.HttpContext.Response.Flush();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七色彩虹 2024-11-23 20:22:46

AFAIK,cmdlet New-ManagementRoleAssignment 不适用于 Office 365 上的小型企业计划 (P1)。但是,默认情况下会为管理员分配模拟权限,因此您必须使用管理员凭据进行连接。

AFAIK, the cmdlet New-ManagementRoleAssignment is not available for the Small Business Plan (P1) on Office 365. However, the administrator is assigned impersonation rights by default so you have to connect with the administrator credentials.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文