创建 Exchange 邮箱 (CDOEXM.IMailboxStore.CreateMailbox) 时出现错误 HRESULT E_FAIL

发布于 2024-07-11 19:20:08 字数 922 浏览 3 评论 0原文

我正在尝试自动化为 AD 用户创建 Exchange 邮箱的过程,但遇到了问题。 调用 CreateMailbox 方法时,我收到错误“调用 COM 组件已返回错误 HRESULT E_FAIL”。 我已安装并引用了 Exchange 管理工具,并使用模拟来获取权限。

这是代码:

            ActiveDs.IADsUser adUser = (ActiveDs.IADsUser)user.NativeObject;
            adUser.AccountDisabled = !Active;
            user.CommitChanges();

            //Set Password
            user.Invoke("SetPassword", Password);
            user.CommitChanges();            

            //Create Mailbox
            IMailboxStore mailbox;
            mailbox = (IMailboxStore)adUser;
            mailbox.CreateMailbox("LDAP://CN=StandardUsers,CN=StandardUsers,CN=InformationStore,CN=xxxxx," +
                "CN=Servers,CN=First Administrative Group,CN=Administrative Groups," +
                "CN=xxxxx Main,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=xxxxx,DC=com");             
            user.CommitChanges();

I am trying to automate the process of creating an Exchange Mailbox for AD users and am running into an issue. When calling the CreateMailbox method I am receiving the error "Error HRESULT E_FAIL has been returned from a call to a COM component". I have installed and referenced the Exchange Management Tools and am using impersonation for permissions.

Here is the code:

            ActiveDs.IADsUser adUser = (ActiveDs.IADsUser)user.NativeObject;
            adUser.AccountDisabled = !Active;
            user.CommitChanges();

            //Set Password
            user.Invoke("SetPassword", Password);
            user.CommitChanges();            

            //Create Mailbox
            IMailboxStore mailbox;
            mailbox = (IMailboxStore)adUser;
            mailbox.CreateMailbox("LDAP://CN=StandardUsers,CN=StandardUsers,CN=InformationStore,CN=xxxxx," +
                "CN=Servers,CN=First Administrative Group,CN=Administrative Groups," +
                "CN=xxxxx Main,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=xxxxx,DC=com");             
            user.CommitChanges();

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

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

发布评论

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

评论(1

情徒 2024-07-18 19:20:08

我最初的反应有点奇怪; 我完全误读了代码。 您所拥有的内容与我们在 Exch 2003 期间在生产环境中使用的内容类似。我们从一个 Web 服务调用代码,该服务以在 AD 和 Exchange 中具有管理员权限的帐户身份运行。

无论如何,这就是 MSDN 现在所说的链接

重要 由于多跃点身份验证问题以及在多线程运行时环境中观察到的意外结果,Microsoft® 不支持在 Microsoft ASP.NET 页面、ASP 网页中使用 CDO for Exchange Management (CDOEXM)或在 Web 服务中。 要创建使用 CDOEXM 功能的基于 Web 的 Microsoft Exchange 管理应用程序,Microsoft 建议将 CDOEXM 包装在分布式组件对象模型 (DCOM) 包中,并从应用程序中调用该包。

My original response was kinda wack; I totally misread the code. What you have is similar to what we had working in production back during Exch 2003. We called the code from a web service that ran as an account that had admin privileges in AD and Exchange.

Anyhow, this is what MSDN is saying now link:

Important Because of issues with multiple-hop authentication and unexpected results observed in multithreaded runtime environments, Microsoft® does not support using CDO for Exchange Management (CDOEXM) in Microsoft ASP.NET pages, ASP Web pages or in Web services. To create Web-based Microsoft Exchange management applications that use CDOEXM functionality, Microsoft recommends wrapping CDOEXM in a Distributed Component Object Model (DCOM) package and calling that package from your application.

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