我有這個功能,創建分發交流羣(此功能效果很好):拒絕訪問交流外殼時,我模仿
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()
功能我得到一個錯誤:
Access Denied : About remote troubleshooting
我已立即進行測試使用
本地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
和會話被成功打開...
- 我已經測試過更改服務帳戶權限(甚至域管理員他被拒絕...):沒有效果
- 我給交換服務器(本地管理員組,...)上的特殊訪問權限:無效
- 我給特價IIS權限(前端,後端,...):無效
爲什麼當我模擬賬戶被拒絕以及如何授予訪問權限?
Finaly我不模仿這個功能,最簡單的方法就是在模擬之後調用這個函數。感謝您的解釋! –