PowerShell Remoting Lync,搜索域控制器时发生Active Directory错误“ -2147016672”

问题描述 投票:2回答:3

我正在尝试通过WcfService配置LyncServer,该服务本身会执行PowerShell远程处理以在Lync计算机上运行Cmdlet。我成功导入了Lync模块,但是当我尝试调用和Lync cmdlet时,例如Get-CsUser我在powershell.Streams.Error中收到错误:

Active Directory错误“ -2147016672”在搜索域控制时发生域“ my.test.domain”中的管理员:“发生操作错误。”

这是我创建运行空间的方式:

PSCredential psCred = new PSCredential(this.Credentials.Domain + "\\" + this.Credentials.UserName, this.Credentials.SecurePassword);
WSManConnectionInfo wsman = new WSManConnectionInfo(uri, c_powerShellShema, psCred);
wsman.AuthenticationMechanism = AuthenticationMechanism.Default;
//wsman.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
//wsman.ProxyAuthentication = AuthenticationMechanism.Negotiate;      

Runspace retval = RunspaceFactory.CreateRunspace();//wsman);
retval.Open();

和我的powershell通话

PowerShell powerShell = PowerShell.Create();
powerShell.Runspace = this.Runspace;
powerShell.AddScript("Import-Module Lync");
powerShell.Invoke();
powerShell.Streams.ClearStreams();
powerShell.AddScript("Get-CsUser);
powerShell.Commands.AddCommand("Out-String");

var retval = powerShell.Invoke();
foreach (var o in retval)
    Console.WriteLine(o.ToString());

foreach (var e in powerShell.Streams.Error)
    Console.WriteLine(e.ToString());

有什么想法吗?运行空间中使用的用户与我以前通过lync管理控制台执行所有lync配置的用户相同,因此他具有所需的所有访问权限。

c# powershell active-directory remoting lync
3个回答
1
投票

我终于在这里找到答案:Powershell v2 remoting and delegation。因此我在该服务器上呼叫了Enable-PsRemoting,并且工作正常。


0
投票

您不使用ASP.NET,但也许How to use the System.DirectoryServices namespace in ASP.NET可以解释您的问题。


0
投票

您正在使用默认身份验证

© www.soinside.com 2019 - 2024. All rights reserved.