首页 > 解决方案 > 使用 C# 连接到 SkypeOnlineConnector

问题描述

我想通过 C# 连接到 SkypeOnlineConnector 端点,然后能够执行从端点下载的命令。

类似于为 Exchange 命令建立连接的方式

示例:交换连接

            string severName = "ps.outlook.com/PowerShell-LiveID?PSVersion=2.0";
            string userName = "name@domain.com";
            string password = "Password";

            System.Security.SecureString secureString = new System.Security.SecureString();
            foreach (char c in password)
                secureString.AppendChar(c);
            PSCredential credential = new PSCredential(userName, secureString);
            WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("https://" + severName), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential)
            {
                AuthenticationMechanism = AuthenticationMechanism.Basic,
                SkipCACheck = true,
                SkipCNCheck = true,
                MaximumConnectionRedirectionCount = 4
            };

我试过这个

            string PSServerName = "admingb1.online.lync.com/OcsPowershellOAuth";
            string UserName = "name@domain.com";
            string Password = "password";

            System.Security.SecureString secureString = new System.Security.SecureString();
            foreach (char c in Password)
                secureString.AppendChar(c);
            PSCredential credential = new PSCredential(UserName, secureString);
            WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("https://" + PSServerName), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential)
            {
                AuthenticationMechanism = AuthenticationMechanism.Basic,
                SkipCACheck = true,
                SkipCNCheck = true,
                MaximumConnectionRedirectionCount = 4
            };

运行上面给我以下错误

System.Management.Automation.Remoting.PSRemotingTransportException : Connecting to remote server admingb1.online.lync.com failed with the following error message : The WinRM client cannot process the request. The authentication mechanism requested by the client is not supported by the server or unencrypted traffic is disabled in the service configuration. Verify the unencrypted traffic setting in the service configuration or specify one of the authentication mechanisms supported by the server.  To use Kerberos, specify the computer name as the remote destination. Also verify that the client computer and the destination computer are joined to a domain. To use Basic, specify the computer name as the remote destination, specify Basic authentication and provide user name and password. Possible authentication mechanisms reported by server: For more information, see the about_Remote_Troubleshooting Help topic.

这是正确的做法还是需要完全不同的方法?

任何帮助,将不胜感激。

标签: c#powershellexchangewebservicesskype-for-business

解决方案


推荐阅读