【发布时间】:2018-03-21 00:59:18
【问题描述】:
我有这个创建分发交换组的功能(这个功能很好用):
private void createDistributionGroup()
{
System.Security.SecureString pass = new System.Security.SecureString();
foreach (char c in password)
pass.AppendChar(c);
PSCredential cred = new PSCredential(username, pass);
WSManConnectionInfo connection = new WSManConnectionInfo(new Uri("http://[my_exchange].[my_domain].com/PowerShell/"), "Microsoft.Exchange", cred);
connection.AuthenticationMechanism = AuthenticationMechanism.Default;
Runspace runspace = RunspaceFactory.CreateRunspace(connection);
PowerShell ps = PowerShell.Create();
try
{
runspace.Open();
ps.Runspace = runspace;
ps.AddCommand("New-DistributionGroup").AddParameter("Name", "GRP_DIF_" + textBox1.Text));
ps.Invoke();
}
finally
{
runspace.Dispose();
runspace = null;
ps.Dispose();
ps = null;
}
}
我必须使用模拟来执行我的应用程序,使用the msdn example 我模拟到一个服务帐户(MSDN 示例运行良好并且模拟成功)。
在实现模拟之前,连接工作正常,因为我在尝试执行 createDistributionGroup() 函数时进行了模拟,因此出现错误:
拒绝访问:关于远程故障排除
我已立即测试在本地 PowerShell 中使用打开远程 PowerShell 会话
$credential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://[my_exchange].[my_domain].com/PowerShell/ -Authentication Default -Credential $credential
Import-PSSession $Session
并且会话已成功打开...
- 我已测试更改服务帐户权限(即使是域管理员也被拒绝...):没有效果
- 我在 Exchange 服务器上授予特殊访问权限(本地管理员组,...):无效
- 我给特殊的 IIS 权限(前端、后端...):没有效果
为什么当我模拟帐户时被拒绝以及如何授予访问权限?
【问题讨论】:
标签: c# powershell exchange-server remote-access impersonation