创建 Exchange 邮箱 (CDOEXM.IMailboxStore.CreateMailbox) 时出现错误 HRESULT E_FAIL
我正在尝试自动化为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最初的反应有点奇怪; 我完全误读了代码。 您所拥有的内容与我们在 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.