473,669 Members | 2,386 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Exchange create mailbox

I have the following code that creates a user and makes a mailbox with it:
private void kandidaatAanmak en(string voornaam, string achternaam, string
gebruikersnaam)
{
string password = "1234567";
DirectoryEntry container, user;
string homeMDB = "";

container = new DirectoryEntry( "LDAP://192.168.0.56/CN=Users,
DC=aoicttest, DC=local");
user = container.Child ren.Add("cn="+v oornaam+" "+achternaa m, "user");
user.Properties["sAMAccountName "].Add(gebruikers naam);
user.CommitChan ges();
user.Invoke("Se tPassword", new object[]{password});
user.Properties["UserAccountCon trol"].Value = 0x200;
user.CommitChan ges();

//Group(wenskandi daten) opzoeken en de kandidaat aan de group
toevoegen
DirectoryEntry groupDE = new DirectoryEntry( );
groupDE.Usernam e = "administrator" ;
groupDE.Passwor d = "1234567";
groupDE.Path = container.Path;
DirectoryEntry groupEntry =
groupDE.Childre n.Find("CN=wens kandidaten", "group");
groupEntry.Invo ke("add", new object[] {user.Path});

CDOEXM.IMailbox Store mailbox;
homeMDB = "CN=Mailbox Store(aoicttest server), CN=First Storage Group,"
+ "CN=Information Store, CN=aoicttestser ver, CN=Servers,"
+ "CN=First Administrative Group, CN=Administrati ve Groups,"
+ "CN=aoictte st ,CN=Microsoft Exchange, CN=Services,"
+ "CN=Configurati on, DC=aoicttest, DC=local";
mailbox = (IMailboxStore) user.NativeObje ct;
mailbox.CreateM ailbox(homeMDB) ;
user.CommitChan ges();
}

Now, the creation of the user goes allright, but the creation of the mailbox
goes wrong. I have the following computername and domainname:
computername(fu ll): aoicttestserver .aoicttest.loca l
domain: aoicttest.local

Please help me with this problem.

Arjen
Mar 20 '07 #1
2 9249
Does this happen if you seperate the two fuctions as two different programs?

I ask this because I have seen this before with Intel and the issue was the
same.

Once you create an object, the entire program runs under the credentials of
that account.

When you make the second call, if your credentials are not in harmony with
the permissions
needed to perform the second call, it fails.

Also, it may be that LDAP hasn't been given enough time to allow for updates
and isn't seeing it.

hth
..
"arjen1984" <ar*******@disc ussions.microso ft.comwrote in message
news:D8******** *************** ***********@mic rosoft.com...
>I have the following code that creates a user and makes a mailbox with it:
private void kandidaatAanmak en(string voornaam, string achternaam, string
gebruikersnaam)
{
string password = "1234567";
DirectoryEntry container, user;
string homeMDB = "";

container = new DirectoryEntry( "LDAP://192.168.0.56/CN=Users,
DC=aoicttest, DC=local");
user = container.Child ren.Add("cn="+v oornaam+" "+achternaa m,
"user");
user.Properties["sAMAccountName "].Add(gebruikers naam);
user.CommitChan ges();
user.Invoke("Se tPassword", new object[]{password});
user.Properties["UserAccountCon trol"].Value = 0x200;
user.CommitChan ges();

//Group(wenskandi daten) opzoeken en de kandidaat aan de group
toevoegen
DirectoryEntry groupDE = new DirectoryEntry( );
groupDE.Usernam e = "administrator" ;
groupDE.Passwor d = "1234567";
groupDE.Path = container.Path;
DirectoryEntry groupEntry =
groupDE.Childre n.Find("CN=wens kandidaten", "group");
groupEntry.Invo ke("add", new object[] {user.Path});

CDOEXM.IMailbox Store mailbox;
homeMDB = "CN=Mailbox Store(aoicttest server), CN=First Storage
Group,"
+ "CN=Information Store, CN=aoicttestser ver, CN=Servers,"
+ "CN=First Administrative Group, CN=Administrati ve
Groups,"
+ "CN=aoictte st ,CN=Microsoft Exchange, CN=Services,"
+ "CN=Configurati on, DC=aoicttest, DC=local";
mailbox = (IMailboxStore) user.NativeObje ct;
mailbox.CreateM ailbox(homeMDB) ;
user.CommitChan ges();
}

Now, the creation of the user goes allright, but the creation of the
mailbox
goes wrong. I have the following computername and domainname:
computername(fu ll): aoicttestserver .aoicttest.loca l
domain: aoicttest.local

Please help me with this problem.

Arjen

Mar 21 '07 #2
I have seen you posted a reply on my problem. Unfortunately, this did not
solve it. When I place it in a file of its own, I still get the same error:
Value does not fall within the expected range.
Can you please give me some more tips?

"Richard T. Edwards" wrote:
Does this happen if you seperate the two fuctions as two different programs?

I ask this because I have seen this before with Intel and the issue was the
same.

Once you create an object, the entire program runs under the credentials of
that account.

When you make the second call, if your credentials are not in harmony with
the permissions
needed to perform the second call, it fails.

Also, it may be that LDAP hasn't been given enough time to allow for updates
and isn't seeing it.

hth
..
"arjen1984" <ar*******@disc ussions.microso ft.comwrote in message
news:D8******** *************** ***********@mic rosoft.com...
I have the following code that creates a user and makes a mailbox with it:
private void kandidaatAanmak en(string voornaam, string achternaam, string
gebruikersnaam)
{
string password = "1234567";
DirectoryEntry container, user;
string homeMDB = "";

container = new DirectoryEntry( "LDAP://192.168.0.56/CN=Users,
DC=aoicttest, DC=local");
user = container.Child ren.Add("cn="+v oornaam+" "+achternaa m,
"user");
user.Properties["sAMAccountName "].Add(gebruikers naam);
user.CommitChan ges();
user.Invoke("Se tPassword", new object[]{password});
user.Properties["UserAccountCon trol"].Value = 0x200;
user.CommitChan ges();

//Group(wenskandi daten) opzoeken en de kandidaat aan de group
toevoegen
DirectoryEntry groupDE = new DirectoryEntry( );
groupDE.Usernam e = "administrator" ;
groupDE.Passwor d = "1234567";
groupDE.Path = container.Path;
DirectoryEntry groupEntry =
groupDE.Childre n.Find("CN=wens kandidaten", "group");
groupEntry.Invo ke("add", new object[] {user.Path});

CDOEXM.IMailbox Store mailbox;
homeMDB = "CN=Mailbox Store(aoicttest server), CN=First Storage
Group,"
+ "CN=Information Store, CN=aoicttestser ver, CN=Servers,"
+ "CN=First Administrative Group, CN=Administrati ve
Groups,"
+ "CN=aoictte st ,CN=Microsoft Exchange, CN=Services,"
+ "CN=Configurati on, DC=aoicttest, DC=local";
mailbox = (IMailboxStore) user.NativeObje ct;
mailbox.CreateM ailbox(homeMDB) ;
user.CommitChan ges();
}

Now, the creation of the user goes allright, but the creation of the
mailbox
goes wrong. I have the following computername and domainname:
computername(fu ll): aoicttestserver .aoicttest.loca l
domain: aoicttest.local

Please help me with this problem.

Arjen


Mar 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1921
by: Manuel Krummenacher | last post by:
Hello! I'm trying to develop an application to manage email-forwardings on an Exchange 2000 Server. Forwardings to external Addresses are requiring a contact with an Exchange account. I can create the contact in the Active Directory, but when I try to create an Exchange Account, I get this error (translated from German):
2
4744
by: Vincent Nguyen | last post by:
Hi, I have problem create exchange 2000 mailbox using CDOEXM in my Web Service application. The error I got was "Catastrophic failure". Here is the code that I have: DirectoryEntry user = new DirectoryEntry("LDAP://fmsamrmc001.amrmc.minicorp.intel.com/"+strDN); user.Properties.Value = "aaamailbox1"; user.CommitChanges();
3
4007
by: maria.s | last post by:
Hi, I try to create a calender-item in the personal calendar folder from an ASP.NET application using XML-HTTP Request (WebDAV). System: Windows 2003 SP1, Exchange 2003 SP1 Configuration IIS: Default Web Site stopped, OWA running on a second virtual site, my application is running on a third virtual site.
0
1294
by: Gabe Matteson | last post by:
Good morning, The point of this posting is to find out a way to insert downloaded email into your exchange mailbox. 1. I know how to download pop3 mail using asp to a web page. 2. i would like to add a link on the exchange webmail options page which i successfully can that would load up my asp page which downloads email from my pop3 mailbox. i.e. my cox address. i would like to send all my mail that shows up in my web page to my exchange...
0
1829
by: Tim Sapp | last post by:
Guys, I am working on a new web site for our company and have started to move my code from VB.Net to C#. I have ran into a snag that I can't seem to figure out. I am trying to create an Exchange mailbox for a user ID that I just created using System.DirectoryServices. I have created the user, set the password, and enabled the account. When I try and create the mailbox I get a "The parameter is incorrect" error message on...
4
3513
by: Tarren | last post by:
Hi, All: I am tasked with the following. I need to write a service to monitor an Exchange mailbox and take action when an email is received, put it in a db, etc. I do not need to send emails through MAPI, only monitor a folder in exchange. Can I use .NET objects to do this or do I absolutely need a 3rd party add-in such as Outlook Redemption. This has to go on an enterprise production server, so the server group will fight me hard...
0
1571
by: Suman | last post by:
Hello Group, I am relatively new to .NET. I am trying to create a user in AD and a corresponding email account in the exchange server from an ASP.NET, C# application. ----------------------------- I have a problem wherein I am able to create a user but am unable to create a mailbox for the user. I "WAS" using exchange 2000.
0
2411
by: arjen1984 | last post by:
I want to create a mailbox-enabled mailbox. First i have used the toturial from microsoft: http://support.microsoft.com/kb/313114 Then my homeMDB string was incorrect. I saw an article , link: http://forums.asp.net/thread/952974.aspx This guy has the same problem as me. I still have that problem. Mine server is a local server, so i have nog second domain name, i think. This i my code of my homeMDB: try { CDOEXM.IMailboxStore...
0
1729
by: rage2001 | last post by:
I have a script (ASP) written which creates an account in AD, creates a folder on our file server and sets its permissions, and then creates a mailbox on the exchange server and sets its permissions... This script use to work fine, and it hasnt been used in 2 months (since we have had no new students since the end of the term). I have part of the script below. There is alot of code above this script which gets executed perfectly....
4
17669
by: pjblecha | last post by:
Hello all: I'm working on a non-web-based (darn it...) application that will be set up as a scheduled task on an Exchange server to run against a mailbox 2-3 times per day. What the app needs to do is read messages in the mailbox, then create appointment items based on filtering the subject line and parsing text from the message body (which will be in HTML format). I have old VBScript that will create the appointment items, set them to a...
0
8383
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8895
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2797
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.