Error when creating mailbox with CreateMailBox method.

O

Ouaes Jamali

I am using C# and ASP.Net to create users and mailboxes. I can create
an user without any problems but the code Blows up when i try to
create a mailbox. Here is the code snippet is am using

DirectoryEntry de = new DirectoryEntry();
DirectoryEntry ParentEntry = new DirectoryEntry();
CDOEXM.IMailboxStore Mailbox;

ParentEntry.Username = username;
ParentEntry.Password = password;
ParentEntry.AuthenticationType = AuthenticationTypes.Secure;
ParentEntry.Path = aDPathPrefix + aDPathSuffix;

de = ParentEntry.Children.Add("cn=" + commonName, "user");
de.Properties["sAMAccountName"].Add(sAMAccountName);
de.CommitChanges();

//This enables the new user.
de.Properties["userAccountControl"].Value = 0x200;
//ADS_UF_NORMAL_ACCOUNT
de.CommitChanges();

Mailbox = (CDOEXM.IMailboxStore) de.NativeObject;
Mailbox.CreateMailbox(aDHomeMDB);
de.CommitChanges();
I get an error "System.Runtime.InteropServices.COMException: An
operations error occurred." on this line
"Mailbox.CreateMailbox(aDHomeMDB);" of my code. I am using
impersonation in my ASP.Net app and the user i am impersonating is a
domain admin. The environment i am working in is C#, ASP.NET, .net
framework 1.1 and Exchange 2003. I have verified the value of the
HomeMDB using ADISEdit utility and it is correct. I have installed
exchange tools on my machine. Any one out there who has an idea
regarding the permissions that have to be setup in ASP.NET to create a
mail box, please feel free to help me out.

Thanks.

-Jamali
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top