简体   繁体   English

如何使用C#和现有的Active Directory用户以编程方式创建Exchange 2010邮箱

[英]How do I programatically create an Exchange 2010 mailbox using C# and an existent Active Directory user

Following posts like How do I programatically create an exchange 2010 mailbox using C# and http://blog.pedroliska.com/2011/07/28/creating-an-exchange-2010-mailbox-from-a-remote-c-program/#comment-250 looks like I will be able to create a mailbox executing cmdlets on the Exchange server from a remote C# program. 以下帖子,例如“ 如何使用C#http://blog.pedroliska.com/2011/07/28/creating-an-exchange-2010-mailbox-from-a-remote-c-program 如何以编程方式创建Exchange 2010邮箱” /#comment-250看起来我将能够从远程C#程序在Exchange服务器上创建一个执行cmdlet的邮箱。

My question now is how do I do to create this new mailbox using an existing Active Directory user account. 现在的问题是如何使用现有的Active Directory用户帐户创建此新邮箱。 I know I can do this on the Exchange UI so I'm just wondering if its possible to do it programatically through the cmdlets and how. 我知道我可以在Exchange UI上执行此操作,所以我只是想知道是否有可能通过cmdlet以及以编程方式进行此操作。

Thanks 谢谢

You can create new user by creating user in Active directory. 您可以通过在Active Directory中创建用户来创建新用户。 I have done it for my project.You have to reference the System.DirectoryServices.dll assembly and the classes are in the System.System.DirectoryServices namespace. 我已经完成了我的项目。您必须引用System.DirectoryServices.dll程序集,并且这些类位于System.System.DirectoryServices命名空间中。

the sample code to connect with Active directory is as follows : 与Active Directory连接的示例代码如下:

        DirectoryEntry ouser = new DirectoryEntry();
        System.DirectoryServices.PropertyCollection userproperties;

        ouser.Path = "LDAP://CN="Username",CN="", DC="Domain",DC=Com";
        ouser.Username = UserNAme;
        ouser.Password = Password;

Rather than calling New-Mailbox , call Enable-Mailbox . 而不是调用New-Mailbox ,而是调用Enable-Mailbox http://technet.microsoft.com/en-us/library/aa998251.aspx http://technet.microsoft.com/zh-CN/library/aa998251.aspx

If your workstation is in a different Site than your exchange server, you're going to need to make sure that you're making your user on the same DC that the Exchange server is using, otherwise, when you try to mail-enable your User you'll find that (s)he doesn't exist yet (as far as the Exchange Server's DC is concerned) 如果您的工作站与Exchange服务器位于不同的站点中,则需要确保将您的用户设置在Exchange服务器正在使用的同一DC上,否则,当您尝试启用邮件时用户,您会发现他还不存在(就Exchange Server的DC而言)

Anyone know a way to determine which DC an ExchangeServer is using (in C#) from remote? 有谁知道一种从远程确定ExchangeServer使用哪个DC的方法(在C#中)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM