首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何访问Lync Online (Office 365)的UCWA端点?

如何访问Lync Online (Office 365)的UCWA端点?
EN

Stack Overflow用户
提问于 2014-08-02 08:54:36
回答 2查看 2.8K关注 0票数 4

UCWA文档指出,UCWA目前只对拥有Lync的用户开放。

尽管如此,如果对Office 365帐户使用Lync Connectivity Analyzer,似乎可以连接到UCWA服务:已完成的移动测试(UCWA)服务。此外,如果我检查这个工具执行的web请求(例如,使用Fiddler ),我可以获取它从Office 365获得的身份验证令牌,并使用它向UCWA发出请求。

  • 看来UCWA是由Office 365曝光的,对吗?似乎使用特定的WebTicket服务来获得身份验证令牌。
  • 是否有任何库对WebTicket服务的使用进行抽象以获得身份验证令牌?有了令牌之后,访问UCWA资源将非常简单--不过,它的库也会很好:)
  • 我找不到太多关于WebTicket服务(WCF)的文档。如果我向https://lyncweb.domain.com/WebTicket/WebTicketService.svc添加服务引用(Visual ),那么选项就不多了--请求和响应消息似乎没有特定的结构,因此调用由该WebTicket服务公开的IssueToken操作非常棘手。

链接:

  • 关于UCWA
  • Lync连接度分析仪
  • LyncDiscover与自动发现号深潜
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-08-04 08:15:13

您做了相当多的调查,根据我的信息,WebTicket应该是UCWA的一个可能的身份验证令牌。

不幸的是,文档仍然正确地说,目前UCWA只支持on安装。对于Lync Online / Office 365,它尚未启用。

Office的用户语音上有一个功能请求,您可以投票和跟踪。正如您所读到的,在这篇文章中,有一些公告即将发布。

https://officespdev.uservoice.com/forums/224641-general/suggestions/5857717-ucwa-for-lync-365

票数 5
EN

Stack Overflow用户

发布于 2015-07-30 01:23:24

它看起来像Office 365至少公开了UCWA功能的一个不错的子集。实际上是一个.NET应用程序,因此很难直接利用它来完成繁重的工作。它不像使用“友好的”库那么好,但在我的各种原型设计中,它对我来说效果很好。通过下面的代码,我可以获得web票证值和UCWA基本URL (通过自动发现),然后到镇上查询API。这不是最漂亮的代码,但有效。

注释:,您需要在中添加对托管DLL的引用。对我来说,这意味着:

  • Credentials.dll
  • LyncConnectivityAnalyzer.Logging.dll
  • LyncConnectivityAnalyzer.Resources.dll
  • LyncWebServices.dll
  • Utilities.dll

您还需要将非托管‘ll复制到与应用程序(例如\bin\文件夹)相同的文件夹中(可能只有一个,但两者我都做了)。

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Security;
using System.Threading.Tasks;
using LyncConnectivityAnalyzer.Logging;
using Microsoft.LyncServer.WebServices;
using Microsoft.Utilities.Credentials;

namespace SM.CoolStuff
{
    /// <summary>
    /// Helper class for performing auto-discovery and authentication to the Lync/Skype UCWA sevice on Office365
    /// </summary>
    public class SkypeHelper
    {
        private string _webTicket;
        private string _ucwaRootPath;
        private readonly ILyncLogging _logger = new Logger();

        /// <summary>
        /// Initializes the connection/authentication/etc.  Once this method completes, <see cref="_webTicket"/> and <see cref="_ucwaRootPath"/> will
        /// be populated.
        /// </summary>
        private async Task Initialize(string userName, SecureString password)
        {
            //Setup the credential
            var userCreds = new Credentials
            {
                UPN = userName,
                SecurePassword = password,
                credsType = CredInputType.CredDialog,
                URI = userName
            };

            //Perform auto-discovery to get the UCWA path
            //We'll just always allow redirects
            ValidateRedirectRequestDelegate alwaysAllowRedirect = (logger, url, destinationUrl) => true;
            var adm = new AutoDiscoverManager(_logger, "http://lyncdiscover." + userCreds.Domain, userCreds.URI, userCreds, alwaysAllowRedirect);
            await adm.StartDiscoveryJourney();

            //Save the path
            _ucwaRootPath = adm.GetAutoDiscoverAddress().ExternalUcwa;

            //Setup the 'validator' that does all the heavy lifting
            var webServicesValidation = new WebServicesValidation(_logger, _ucwaRootPath, userCreds)
            {
                HttpRequestBody = ApplicationPostBody,
                customHeaders = CustomHeaders,
                getPost = HttpMethod.Post
            };

            //Make a first request that should gracefully fail with 'authorization required'
            await webServicesValidation.CheckURL(_ucwaRootPath, false);

            //Now authorize the request
            await webServicesValidation.TryURLAuth(_ucwaRootPath);

            //Use some ugly reflection to get the ticket value.  There may be a better way but this works
            _webTicket = (string)WebTicketField.GetValue(webServicesValidation);
        }

        /// <summary>
        /// Example usage
        /// </summary>
        public async Task DoSomethingOnSkype()
        {
            //If you already have a SecureString, might as well use that.  Otherwise, convert an 'insecure' string to be 'Secure'
            var secureString = new SecureString();
            "TopSecret".ToList().ForEach(secureString.AppendChar);

            //Do the initialization
            await Initialize("user@somewhere.com", secureString);

            //TODO: Use _webTicket and _host to query something
        }

        private static readonly string ApplicationPostBody =
            string.Concat(
                "<input xmlns=\"http://schemas.microsoft.com/rtc/2012/03/ucwa\"><property name=\"culture\">en-US</property><property name=\"endpointId\">44:D8:84:3C:68:68</property><property name=\"type\">Phone</property><property name=\"userAgent\">",
                //TODO: Your app name here
                "LyncConnectivityAnalyzer", "/",
                //TODO: Your app version here
                "5.0.8308.582",
                " (Windows OS 6.0)</property></input>");

        private static readonly Dictionary<string, string> CustomHeaders = new Dictionary<string, string>
        {
            {"Accept", "application/vnd.microsoft.com.ucwa+xml"},
            {"Content-Type", "application/vnd.microsoft.com.ucwa+xml"},
            {"X-MS-Namespace", "internal"},
            {"Connection", "keep-alive"},
            {"Proxy-Connection", "keep-alive"}
        };

        private static readonly FieldInfo WebTicketField = FindWebTicketField();

        private static FieldInfo FindWebTicketField()
        {
            var fieldInfo = typeof(WebServicesValidation).GetField("_webticket", BindingFlags.Instance | BindingFlags.NonPublic);
            if (fieldInfo == null)
            {
                throw new ApplicationException("Could not find private _webticket field");
            }
            return fieldInfo;
        }
   }
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25093344

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档