PDA

View Full Version : امکان ایجاد mail box توسط برنامه نویسی



نیک نژاد
جمعه 18 اردیبهشت 1383, 13:34 عصر
با سلام
چطور میشه با استفاده از برنامه نویسی ( ترجیحا سی شارپ ) این امکان رو برای صاحب سایت فراهم کرد تا بتونه برای یوزرهای خودش "میل باکس" بسازه . ( نمی خواهیم وارد کنترل پنل سایت بشه )
البته این مطلب رو توی msdn2003 پیدا کردیم ولی پارامتراش نمی دونیم چیه . . .




<span dir=ltr>HOW TO: Create a Mailbox-Enabled Recipient by Using C# .NET</span>

<span dir=ltr>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;
}
}
}</span>

نیک نژاد
پنج شنبه 24 اردیبهشت 1383, 14:33 عصر
کسی جواب این سوال رو بلد نیست ؟ :cry:

Inprise
جمعه 25 اردیبهشت 1383, 16:33 عصر
دوست عزیز ،

راهکار یکتائی برای این مساله وجود نداره . کد فوق یه مثال است برای وقتی که تو یک دامنه و کنترلگر دامنه سازگار با LDAP داری ( DirectoryServices NameSpace ) و سرویس دهنده ات هم M$ Exchange هست . ایمیل سرورهای مختلف از روشها و API های مختلفی برای ایجاد اکانت کاربری استفاده میکنن . بعد از اطلاع از نام و نسخهء سرویس دهندهء ایمیلی که ازش استفاده میکنی ، به احتمال قریب به یقین با مراجعه به سایت توسعه دهنده اش میتونی راهنمای نحوهء استفاده از API های همون ایمیل سرور و تولید اکانت و ... رو دریافت کنی .

موفق باشی