error creating exchange mailbox using c# under asp.net

error creating exchange mailbox using c# under asp.net

Post by Niels Holo » Thu, 13 Feb 2003 23:36:09



hello all,

I have different problems creating an exchange 2000 mailbox for an ads
user with c#. I have a domain controller and an exchange mailbox store
who are different and the iis is also another server. all three are in
the same ADS domain. The Home MDB string is entirely correct because
I've copied it directly from ADSIedit. I've also changed my web.config
to impersonate so that the script runs under a domain user. This user
has also the 'Act as part of the operating system' privilidges and the
administrator rights on the exchange server.
I thought I#ve made everything correct but I still get the following
error messages. Can anybody help???

----------------------------------------------------
The following error occurs:

Exception Details: System.ArgumentException: The parameter is
incorrect.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: The parameter is incorrect.]
 CDOEXM.IMailboxStore.CreateMailbox(String HomeMDBURL) +0
 WebApplication2.WebForm1.Page_Load(Object sender, EventArgs e)
 System.Web.UI.Control.OnLoad(EventArgs e) +67
 System.Web.UI.Control.LoadRecursive() +29
 System.Web.UI.Page.ProcessRequestMain() +724
------------------------------------------
This is my source code:

IADsUser objUser;
CDOEXM.IMailboxStore mailbox;
DirectoryEntry newuser =
de.Children.Add("CN="+Request.Form["displayname"],"User");

newuser.Properties["sAMAccountName"].Add(Request.Form["displayname"]);
newuser.Properties["userAccountControl"].Value=0x200;
newuser.CommitChanges();

objUser= (ActiveDs.IADsUser) newuser.NativeObject;
objUser.AccountDisabled=false;
objUser.SetInfo();
objUser.ChangePassword("","xxx");
objUser.FullName="Testing User";
newuser.CommitChanges();
objUser.SetInfo();

mailbox = (CDOEXM.IMailboxStore)objUser;
string homeMDB = "LDAP://ADCSERVER.DOMAIN.NET/CN=Mailbox Store
(EXCHANGE_STORE),CN=First Storage
Group,CN=InformationStore,CN=EXCHANGE_STORE,CN=Servers,CN=Administrative
Groups,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=DOMAIN,DC=NET";

mailbox.CreateMailbox(homeMDB);
objUser.SetInfo();
-----------------------------------

thanks,

niels

 
 
 

error creating exchange mailbox using c# under asp.net

Post by Siegfried Weber [MVP » Sun, 16 Feb 2003 09:25:09


Try to remove the server name from the mailbox url like
this:

string homeMDB = "LDAP://CN=Mailbox Store
(EXCHANGE_STORE),CN=First Storage

Cheers,

Siegfried

Quote:>-----Original Message-----
>hello all,

>I have different problems creating an exchange 2000
mailbox for an ads
>user with c#. I have a domain controller and an exchange
mailbox store
>who are different and the iis is also another server.
all three are in
>the same ADS domain. The Home MDB string is entirely
correct because
>I've copied it directly from ADSIedit. I've also changed
my web.config
>to impersonate so that the script runs under a domain
user. This user
>has also the 'Act as part of the operating system'
privilidges and the
>administrator rights on the exchange server.
>I thought I#ve made everything correct but I still get
the following
>error messages. Can anybody help???

>----------------------------------------------------
>The following error occurs:

>Exception Details: System.ArgumentException: The
parameter is
>incorrect.

>Source Error:

>An unhandled exception was generated during the
execution of the
>current web request. Information regarding the origin
and location of
>the exception can be identified using the exception
stack trace below.

>Stack Trace:

>[ArgumentException: The parameter is incorrect.]
> CDOEXM.IMailboxStore.CreateMailbox(String HomeMDBURL) +0
> WebApplication2.WebForm1.Page_Load(Object sender,
EventArgs e)
> System.Web.UI.Control.OnLoad(EventArgs e) +67
> System.Web.UI.Control.LoadRecursive() +29
> System.Web.UI.Page.ProcessRequestMain() +724
>------------------------------------------
>This is my source code:

>IADsUser objUser;
>CDOEXM.IMailboxStore mailbox;
>DirectoryEntry newuser =
>de.Children.Add("CN="+Request.Form

["displayname"],"User");

- Show quoted text -

Quote:

>newuser.Properties["sAMAccountName"].Add(Request.Form
["displayname"]);
>newuser.Properties["userAccountControl"].Value=0x200;
>newuser.CommitChanges();

>objUser= (ActiveDs.IADsUser) newuser.NativeObject;
>objUser.AccountDisabled=false;
>objUser.SetInfo();
>objUser.ChangePassword("","xxx");
>objUser.FullName="Testing User";
>newuser.CommitChanges();
>objUser.SetInfo();

>mailbox = (CDOEXM.IMailboxStore)objUser;
>string homeMDB = "LDAP://ADCSERVER.DOMAIN.NET/CN=Mailbox
Store
>(EXCHANGE_STORE),CN=First Storage
>Group,CN=InformationStore,CN=EXCHANGE_STORE,CN=Servers,CN
=Administrative
>Groups,CN=Microsoft

Exchange,CN=Services,CN=Configuration,DC=DOMAIN,DC=NET";

- Show quoted text -

Quote:

>mailbox.CreateMailbox(homeMDB);
>objUser.SetInfo();
>-----------------------------------

>thanks,

>niels
>.


 
 
 

error creating exchange mailbox using c# under asp.net

Post by Niels Holo » Wed, 19 Feb 2003 22:00:23


hello,

this doesn't help. I still got the same error message.
And once again the ADC and the Mailbox Store are two different servers
so I think putting the ADC in front was correct.

niels


Quote:> Try to remove the server name from the mailbox url like
> this:

> string homeMDB = "LDAP://CN=Mailbox Store
> (EXCHANGE_STORE),CN=First Storage

> Cheers,

> Siegfried

> >-----Original Message-----
> >hello all,

> >I have different problems creating an exchange 2000
>  mailbox for an ads
> >user with c#. I have a domain controller and an exchange
>  mailbox store
> >who are different and the iis is also another server.
>  all three are in
> >the same ADS domain. The Home MDB string is entirely
>  correct because
> >I've copied it directly from ADSIedit. I've also changed
>  my web.config
> >to impersonate so that the script runs under a domain
>  user. This user
> >has also the 'Act as part of the operating system'
>  privilidges and the
> >administrator rights on the exchange server.
> >I thought I#ve made everything correct but I still get
>  the following
> >error messages. Can anybody help???

> >----------------------------------------------------
> >The following error occurs:

> >Exception Details: System.ArgumentException: The
>  parameter is
> >incorrect.

> >Source Error:

> >An unhandled exception was generated during the
>  execution of the
> >current web request. Information regarding the origin
>  and location of
> >the exception can be identified using the exception
>  stack trace below.

> >Stack Trace:

> >[ArgumentException: The parameter is incorrect.]
> > CDOEXM.IMailboxStore.CreateMailbox(String HomeMDBURL) +0
> > WebApplication2.WebForm1.Page_Load(Object sender,
>  EventArgs e)
> > System.Web.UI.Control.OnLoad(EventArgs e) +67
> > System.Web.UI.Control.LoadRecursive() +29
> > System.Web.UI.Page.ProcessRequestMain() +724
> >------------------------------------------
> >This is my source code:

> >IADsUser objUser;
> >CDOEXM.IMailboxStore mailbox;
> >DirectoryEntry newuser =
> >de.Children.Add("CN="+Request.Form
>  ["displayname"],"User");

> >newuser.Properties["sAMAccountName"].Add(Request.Form
>  ["displayname"]);
> >newuser.Properties["userAccountControl"].Value=0x200;
> >newuser.CommitChanges();

> >objUser= (ActiveDs.IADsUser) newuser.NativeObject;
> >objUser.AccountDisabled=false;
> >objUser.SetInfo();
> >objUser.ChangePassword("","xxx");
> >objUser.FullName="Testing User";
> >newuser.CommitChanges();
> >objUser.SetInfo();

> >mailbox = (CDOEXM.IMailboxStore)objUser;
> >string homeMDB = "LDAP://ADCSERVER.DOMAIN.NET/CN=Mailbox
>  Store
> >(EXCHANGE_STORE),CN=First Storage
> >Group,CN=InformationStore,CN=EXCHANGE_STORE,CN=Servers,CN
>  =Administrative
> >Groups,CN=Microsoft
>  Exchange,CN=Services,CN=Configuration,DC=DOMAIN,DC=NET";

> >mailbox.CreateMailbox(homeMDB);
> >objUser.SetInfo();
> >-----------------------------------

> >thanks,

> >niels
> >.

 
 
 

error creating exchange mailbox using c# under asp.net

Post by Siegfried Weber [MVP » Thu, 20 Feb 2003 02:23:00



> hello all,

> I have different problems creating an exchange 2000 mailbox for an ads
> user with c#. I have a domain controller and an exchange mailbox store
> who are different and the iis is also another server. all three are in
> the same ADS domain. The Home MDB string is entirely correct because
> I've copied it directly from ADSIedit. I've also changed my web.config
> to impersonate so that the script runs under a domain user. This user
> has also the 'Act as part of the operating system' privilidges and the
> administrator rights on the exchange server.
> I thought I#ve made everything correct but I still get the following
> error messages. Can anybody help???

[snip]

Try to remove the Windows DC name from the mailbox URL. Worked for me all
the time.

--
<Cheers:Siegfried runat="server" />

Development Lead,

Microsoft Most Valuable Professional (MVP) - Exchange Server

CDOLive LLC - The Microsoft Messaging and Collaboration Application
Experts http://www.cdolive.com

Please reply to the newsgroups so that others can benefit from the
discussion. Questions by e-mail are discarded without further notice.

 
 
 

error creating exchange mailbox using c# under asp.net

Post by Niels Holo » Thu, 20 Feb 2003 23:08:06


I've removed the DC server from the string but it doesn't help. I
still got this error message:
----
Exception Details: System.ArgumentException: The parameter is
incorrect.
----

and my sourcecode now is the following:

mailbox = (CDOEXM.IMailboxStore)objUser;
string homeMDB = "LDAP://CN=Mailbox Store
(EXCHANGE_STORE),CN=First Storage
Group,CN=InformationStore,CN=EXCHANGE_STORE,CN=Servers,CN=Administrative
Groups,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=DOMAIN,DC=NET";

any other ideas?

 
 
 

error creating exchange mailbox using c# under asp.net

Post by Siegfried Weber [MVP » Thu, 20 Feb 2003 17:03:25



> this doesn't help. I still got the same error message.
> And once again the ADC and the Mailbox Store are two different servers
> so I think putting the ADC in front was correct.

You really don't need to include the Windows domain controller name in the
mailbox url. It has been mentioned in some old Exchange 2000 SDK builds but
that was wrong and it has been corrected since.

If your code still fails the account you used either doesn't have valid
permissions or the mailbox url string is incorrect.
Here's a sample string that works for me:

strHomeMDBUrl = "CN=Mailbox Store (EXCHANGESERVER),CN=First Storage Group,"
& _
  "CN=InformationStore,CN="EXCHANGESERVER,CN=Servers," & _
  "CN=First Administrative Group,CN=Administrative Groups," & _
  "CN=EXCHANGEORG,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=DOMAIN,DC=NET"

From what I gather your string does not include the Exchange organization
and is also missing the administrative group name
--
<Cheers:Siegfried runat="server" />

Development Lead,

Microsoft Most Valuable Professional (MVP) - Exchange Server

CDOLive LLC - The Microsoft Messaging and Collaboration Application
Experts http://www.cdolive.com

Please reply to the newsgroups so that others can benefit from the
discussion. Questions by e-mail are discarded without further notice.

 
 
 

error creating exchange mailbox using c# under asp.net

Post by Niels Holo » Fri, 21 Feb 2003 18:57:11


hi again

what are necessary permissions?
At the moment our IIS-user has standard rights. The user we bind with
is in the domain administrator group, in the exchange administrator
group and has local administrative rights on the exchange server.

Niels

 
 
 

error creating exchange mailbox using c# under asp.net

Post by Siegfried Weber [MVP » Sun, 23 Feb 2003 01:46:50



Quote:

> what are necessary permissions?
> At the moment our IIS-user has standard rights. The user we bind with
> is in the domain administrator group, in the exchange administrator
> group and has local administrative rights on the exchange server.

CDOEXM does not allow to "bind" with a particular user. From what you say
you use particular user credentials with System.DirectoryServices but your
code runs in IIS with the default IUSR_xx account? That will not work. If
using CODEXM you must run the whole application with a user account with
proper credentials.

--
<Cheers:Siegfried runat="server" />

Development Lead,

CDOLive LLC - The Microsoft Messaging and Collaboration Application
Experts http://www.cdolive.com

Please reply to the newsgroups so that others can benefit from the
discussion. Questions by e-mail are discarded without further notice.

 
 
 

1. Create an Exchange Mailbox-Enabled user with an ASP.NET application

Hi, there

I am trying to write an ASP.NET (with CodeBehind in c#) application
that adds an Exchange Mailbox-enabled user in an Active Directory.

I set up all the configurations issues:
* Install Advanced Server Admin Tools.
* Install Exchange Management Tools in order to be able to work with
CDOEXM.
* Validate my installation by running a VB sample application AND a C#
console application that do the job (adding a new E-mailboxed user in
AD).

But, now I am jammed because the code DOESN'T work within the ASP.NET
application...

NOTE: The IIS box is different from the Domain Controller box and the
Exchange box.

I think I am facing kinda permissions issues because the ASPNET user
(which runs the ASPNET code Within IIS)  has not the requisite
credentials to run
the critical CDOEXM Com code?

Depending of how I set up the permissions (within IIS, within
web.config with <identity impersonate> tag),
I get differents errors when i call the CreateMailbox method in the
ASP.NET web app:
-System.InvalidArgument Exception
-"Catastrophic Failure" error (sic!)

The only way I managed to run the code is with:
-1- The web.config <identity> tag written as follows: <identity
impersonate="true" username=<MyDomain\MyAccount> password=<mypassword>
where MyDomain\MyAccount is my current login. Besides, this Account is
in the Domain a member of "Domain Admins" group. )

-2- The following settings of the "Authentication Methods" windows
from the "Directory Security" of "MyWebApp" Properties within IIS
Management Console:
      --> "Anonymous access" checked with "IUSR_MACHINE" in the
"edit..." box.
      --> "Integrated Windows authentication" checked in the
"Authenticated access"

But it is not acceptable, as I have in my Web application an
Applicative
login: only the person who logged in as the Admin user of my
application
(NOT the Domain Admin user) should be able to call the page that do
the "Mailbox enabled User" job...

So the question could be:
Where do I deal with this issue?
- In the "web.config" file of my WebApp with <impersonate="true"
etc...> ?
- In MyWebApp IIS properties?
- In the management of permissions for the differents ASP*
users:(IUSR_MYMACHINE user, ASPNET user, SYSTEM user)
- ElseWhere? (the machine.config .NET file?)

It is possible in ASP.NET to declare that ONE specific page must run
with specific permissions?

Sorry for being so verbose... I tried to be explicit.

Thanks for your help,

Num

2. Delivery error

3. Creating a Calendar entry using ASP.NET breaks Outlook

4. Exchange's internal X.400 directory versus X.400 user addresses

5. Native Mode

6. using C#.NET and ASP.NET to customize OWA 2K

7. They just upped the price!!

8. Asp.Net VB.Net Emailing from code using Specific Account

9. HOTO: Creating Mailboxes with ASP/VB.NET

10. HOTO: Creating Mailboxes from ASP/VB.NET

11. OWA, WSS and ASP.net - Asp.net not parsing

12. How to create an Exchange Mailbox using ASP???