我正在嘗試自動爲AD用戶創建Exchange郵箱並且遇到問題。當調用CreateMailbox方法時,我收到錯誤「錯誤HRESULT E_FAIL已從調用COM組件返回」。我已經安裝並引用了Exchange管理工具,並使用模擬權限。創建Exchange郵箱時發生HRESULT E_FAIL錯誤(CDOEXM.IMailboxStore.CreateMailbox)
下面是代碼:
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();
adUser是一個IADsUser對象,用戶是DirectoryEntry – Matt 2009-01-16 16:46:24