Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreateMailbox fails on Exchange 2000

2 views
Skip to first unread message

Steve

unread,
Nov 27, 2001, 8:13:03 AM11/27/01
to
Hi!

Using the code below in a console application I am able to create an
Exchange 2000 mailbox in AD for a previously created user.
My problem is that the very same code fails on the CreateMailbox call
when I run the program as a Win service. The error code is
-2147467259.
pDataSource->get_DataSource, pDataSource->Open and
pPerson->QueryInterface work fine.
When running the console app I am logged in as a user with admin
rights for AD and Exchange and it works fine.
I run the Win service using this same admin account on the Exchange
server. I have even sent the same admin details in the
pDataSource->Open call.
I am completely stumped on this one, (unforunately I am very much a
COM novice!)
Could it be something to with namespace? Any other ideas?

regards /Steve

//----------------------------------------------------------------------

#import "C:\Program Files\Common Files\Microsoft Shared\CDO\cdoex.dll"
no_namespace raw_interfaces_only rename("Folder","CDOEXFolder")
#import "D:\Program Files\Exchsrvr\BIN\cdoexm.dll" no_namespace
raw_interfaces_only
#import "C:\Program Files\Common Files\System\ado\msado15.dll"
no_namespace rename("EOF","adoEOF"), named_guids


IPersonPtr pPerson(__uuidof(Person));
IMailboxStorePtr pMailbox;
IDataSourcePtr pDataSource;

_bstr_t PathName = "LDAP://.....
_bstr_t PathNameMDB = "CN=....

hr = pPerson->get_DataSource(&pDataSource);
if( hr == S_OK )
{
hr = pDataSource->Open(
PathName, //(BSTR)strURL,
NULL,
adModeReadWrite,
adFailIfNotExists,
adOpenSource,
L"domain\adminuser", //bstr_t(),
L"password" ); //bstr_t());
}

if( hr == S_OK )
{
//Get MailBoxStore and mailbox-enable the user.
hr = pPerson->QueryInterface(
__uuidof(IMailboxStore),
(void**)&pMailbox);
}

if( hr == S_OK )
{
hr = pMailbox->CreateMailbox( PathNameMDB );
}

if( hr == S_OK )
{
hr = pDataSource->Save();
}
//----------------------------------------------------------------------

0 new messages