| samAccountName | 帳號名稱 |
| displayName | 顯示名稱 |
| distinguishedName | |
| msExchMailboxGuid | 信箱的Guid |
| msExchOwningServer | |
| legacyExchangeDN | |
| homemdb | The URL of the mailbox store of the recipient |
| msExchHomeServerName | |
| mailNickName | email的名稱 |
| msExchVersion | |
| msExchRecipientDisplayType | |
| msExchRecipientTypeDetails | |
| mDBuseDefaults | 使用信箱儲存區默認設置,true:使用預設大小 false:自訂大小 |
| mDBStorageQuota | Issue warning at (KB) 達到該限度時發出警告(KB) 例:3GB->3145728=3*1024*1024 |
| mDBOverQuotaLimit | Prohibit send at (KB) 達到該限度時禁止發送(KB) |
| mDBOverHardQuotaLimit | Prohibit send and receive at (KB) 達到該限度時禁止發送和接收 (KB) |
DirectoryEntry directoryEntryUser = new DirectoryEntry(path);
string userName = (string) directoryEntryUser.Properties["samaccountname"][0];
if (directoryEntryUser.Properties.Contains("msExchMailboxGuid") == false)
{
if (directoryEntryUser.Properties.Contains("displayName") == false)
{
directoryEntryUser.Properties["displayName"].Add(userName);
}
DirectoryEntry directoryEntryMailStore = new DirectoryEntry(pathMailStore);
string homeMDB = (string) directoryEntryMailStore.Properties["distinguishedName"][0];
string msExchHomeServerNamePath = _AD.Protocol + _AD.Server + (string) directoryEntryMailStore.Properties["msExchOwningServer"][0];
tem.DirectoryServices.DirectoryEntry directoryEntryMailServer = new DirectoryEntry(msExchHomeServerNamePath);
string msExchHomeServerName = (string) directoryEntryMailServer.Properties["legacyExchangeDN"][0];
string legacyExchangeDN = msExchHomeServerName.Substring(0, msExchHomeServerName.IndexOf("cn=")) + "cn=Recipients/cn=" + userName;
directoryEntryUser.Properties["homemdb"].Value= homeMDB;
directoryEntryUser.Properties["msExchHomeServerName"].Value = msExchHomeServerName;
directoryEntryUser.Properties["mailNickName"].Value = userName;
directoryEntryUser.Properties["legacyExchangeDN"].Value = legacyExchangeDN;
if (directoryEntryMailServer.Properties.Contains("msExchVersion"))
{
directoryEntryUser.Properties["msExchVersion"].Value = directoryEntryMailServer.Properties["msExchVersion"][0];
directoryEntryUser.Properties["msExchRecipientDisplayType"].Value = 1073741824; directoryEntryUser.Properties["msExchRecipientTypeDetails"].Value = 1;
}
Guid guid = Guid.NewGuid();
directoryEntryUser.Properties["msExchMailboxGuid"].Add(guid.ToByteArray());
}
directoryEntryUser.CommitChanges();
}









