修改 香港专业教育学院差不多,现在有错误消息,它找不到交换数据库。我在另一台服务器上运行该服务然后交换,所以我认为我必须使用UNC路径。 MyServer01 \ First Storage Group \ Mailbox Database.edb虽然不起作用...
嗨! 我在这里感到很沮丧,感觉头疼得厉害,我差不多把我的电脑扔出窗外......
这是问题,我想通过Sharepoint在Active Directory中创建一个新用户,在Sharepoint列表下面运行一个worflow,它捕获变量并将它们发送到webservice,在web目录中创建用户。这很好用,但用户还需要一个邮箱。 那么我们该怎么办?我们将邮件属性设置为所需的电子邮件地址,并找到属性“创建邮箱”....说什么?它在哪里? NOOOOOESSS它不再存在,MS决定它需要更复杂,现在唯一的方法是使用powershell废话......
这就是为什么我在这里,我搜索了一些有关这方面的信息并找到了一些可以解决这个问题的代码,但是,那就是我遇到的问题,web服务不能在Exchange服务器上运行,而是在不同的服务器上运行, webservice需要连接到交换服务器来运行powershellshizzle ...找不到任何关于此的信息,找不到任何示例等等...
hlep ... F1 ......等
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Management.Automation.Runspaces;
using Microsoft.PowerShell.Commands;
using System.Web.Services;
using System.DirectoryServices;
namespace WebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public void CreateADUser(string domain, string domainPostFix, string firstName, string emailaddress, string lastName, string department, string loginName, string password)
{
DirectoryEntry AD = null;
DirectoryEntry NewUser = null;
AD = new DirectoryEntry("LDAP://OU=Users,DC=" + domain + ",DC=" + domainPostFix);
NewUser = AD.Children.Add("CN=" + firstName + " " + lastName, "user");
NewUser.Properties["samAccountName"].Add(loginName);
NewUser.Properties["name"].Add(firstName + " " + lastName);
NewUser.Properties["displayname"].Add(firstName + " " + lastName);
NewUser.Properties["givenName"].Add(firstName);
NewUser.Properties["sn"].Add(lastName);
NewUser.Properties["userprincipalname"].Add(loginName + "@" + domain + "." + domainPostFix);
NewUser.CommitChanges();
NewUser.Invoke("SetPassword", new object[] { password });
NewUser.CommitChanges();
// E-mail shizzle, don't understand it yet, hopefully it works, if not, don't blame me -Erik
RunspaceConfiguration runspaceConf = RunspaceConfiguration.Create();
PSSnapInException PSException = null;
PSSnapInInfo info = runspaceConf.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out PSException);
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConf);
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
Command command = new Command("New-Mailbox");
command.Parameters.Add("Name", "TestName");
//Enabling user account
int val = (int)NewUser.Properties["userAccountControl"].Value;
NewUser.Properties["userAccountControl"].Value = val & ~0x2;
NewUser.CommitChanges();
NewUser.Close();
}
答案 0 :(得分:1)
This帖子解释了将要发生的事情。基本上,Exch2003中曾经有一些名为RUS的东西,它为“部分配置”的用户创建了邮箱。因此,您可以通过LDAP创建用户,并且RUS将在下一次传递时选择新用户,并通过创建邮箱并修复其他AD属性来完成该过程。
现在,2007年RUS已经消失,但您可以通过在Exchange服务器上安排一些cmdlet定期运行(例如使用'at'命令)来获得相同的功能。
答案 1 :(得分:0)
运行此应用程序的计算机需要安装Exchange管理工具,以便可以使用Exchange管理管理单元。
您运行它的帐户还需要拥有Exchange的管理权限。