Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 31st, 2004, 12:03 PM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get certain ADSI Attributes

Well I'm writing a program, that creats a Active Directory User and its mailbox in Exchange 2003.

In msdn I found this code:
Code:
using System;
using CDOEXM;
using System.DirectoryServices;

namespace MBTest
{
     class Class1
     {
          [STAThread]
          static void Main(string[] args)
          {
               //TODO: Change these items to values for your domain or organization.
               string defaultNC = "DC=yourdomain,DC=com";
               string alias = "jsmith";
               string fullName = "Joseph Smith";
               string password = "TestMb123.";
               string domainName = "yourdomain.com";
               string homeMDB = "CN=Mailbox Store (Your Server),CN=Your Storage Group,"
                         + "CN=InformationStore,CN=Your Server,CN=Servers,"
                         + "CN=Your Administrative Group,CN=Administrative Groups,"
                         + "CN=Your Org,CN=Microsoft Exchange,CN=Services,"
                         + "CN=Configuration,DC=Yourdomain,DC=Com";

               DirectoryEntry container, user;
               CDOEXM.IMailboxStore mailbox;

               //This creates the new user in the "users" container.
               //Set the sAMAccountName and the password
               container = new DirectoryEntry("LDAP://cn=users," + defaultNC);
               user = container.Children.Add("cn=" + fullName, "user");
               user.Properties["sAMAccountName"].Add(alias);
               user.CommitChanges();
               user.Invoke("SetPassword", new object[]{password});

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

               //Obtain the IMailboxStore interface, create the mailbox, and commit the changes
               mailbox = (IMailboxStore)user.NativeObject;
               mailbox.CreateMailbox(homeMDB);
               user.CommitChanges();

               return;
          }
     }
}
Will this code work with Exchange 2k3 too, because it is for Exchange 2k.

The central question of my thread is something else. At the beginning of the Code, there is the Attribute homeMDB set with a certain value.

In your Book "professional c#" there is in chapter dealing with ad a sample code, where you enter server, username and password, and the program gets the defaultNamingContext of the domain.

Is there any way, that I can get the value for homeMDB in the same way, as the defaultNamingContext, so that this code works on any server?

thx
Herbert

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ADSI mikedeepak Classic ASP Professional 1 August 13th, 2004 06:33 PM
ADSI problem yeewaitu Classic ASP Professional 5 February 24th, 2004 03:51 PM



All times are GMT -4. The time now is 10:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.