我正在尝试从模拟特定用户的ASPX页面执行Add-Mailboxpermission。来自MSExchange公共源的应用程序错误记录在Web服务器的事件查看器中。
Watson报告将发送到dw20.exe以获取进程ID:2992,参数:E12,c-buddy-RTL-AMD64,08.03.0083.006,w3wp,MEDDirectory,MEDDConnectionPoolManager.BlockImpersonatedCallers,MECommon.FailFastException ,c84f,08.03.0213.000。 ErrorReportingEnabled:False
使用相同的代码执行不同的Exchange CMDlet,包括模拟调用,并且没有任何错误地完成。
String ErrorText = "";
RunspaceConfiguration config = RunspaceConfiguration.Create();
PSSnapInException warning;
sDecryptedPwd = SecurityManager.Decrypt(AdminPassword, true);
using (new Impersonator(AdminUserName, "domain name", sDecryptedPwd))
{
// Load Exchange PowerShell snap-in.
config.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out warning);
if (warning != null)
throw warning;
using (Runspace thisRunspace = RunspaceFactory.CreateRunspace(config))
{
try
{
thisRunspace.Open();
using (Pipeline thisPipeline = thisRunspace.CreatePipeline())
{
//Please change parameter values.
thisPipeline.Commands.Add("Add-MailboxPermission");
thisPipeline.Commands[0].Parameters.Add("Identity", sMailboxName);
thisPipeline.Commands[0].Parameters.Add("User", sUserName);
thisPipeline.Commands[0].Parameters.Add("AccessRights", sAccessRights);
thisPipeline.Commands[0].Parameters.Add("DomainController", sDomainController);
iLogManager.Info("Identity: " + sMailboxName + " User: " + sUserName + " AccessRights: " + sAccessRights + " DomainController: " + sDomainController);
try
{
thisPipeline.Invoke();
iLogManager.Info(thisPipeline.Commands[0].CommandText);
}
catch (Exception ex)
{
ErrorText = "Error: " + ex.ToString();
}
// Check for errors in the pipeline and throw an exception if necessary.
if (thisPipeline.Error != null && thisPipeline.Error.Count > 0)
{
StringBuilder pipelineError = new StringBuilder();
pipelineError.AppendFormat("Error calling Add-MailboxPermission.");
foreach (object item in thisPipeline.Error.ReadToEnd())
{
pipelineError.AppendFormat("{0}\n", item.ToString());
}
ErrorText = ErrorText + "Error: " + pipelineError.ToString() + Environment.NewLine;
}
}
}
finally
{
thisRunspace.Close();
}
}
}
if (ErrorText == "")
return "no error occurred.";
else
return ErrorText;
Exchange是否允许模拟修改ACL的Exchange CMDlet,或者我在这里做错了什么..
任何人都可以在这里帮助我,没有太多关于通过ASPX页面模拟的Exchange Powershell CMdlet的信息。