UCWA文档指出,UCWA目前只对拥有Lync的用户开放。
尽管如此,如果对Office 365帐户使用Lync Connectivity Analyzer,似乎可以连接到UCWA服务:已完成的移动测试(UCWA)服务。此外,如果我检查这个工具执行的web请求(例如,使用Fiddler ),我可以获取它从Office 365获得的身份验证令牌,并使用它向UCWA发出请求。
链接:
发布于 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
发布于 2015-07-30 01:23:24
它看起来像Office 365至少公开了UCWA功能的一个不错的子集。实际上是一个.NET应用程序,因此很难直接利用它来完成繁重的工作。它不像使用“友好的”库那么好,但在我的各种原型设计中,它对我来说效果很好。通过下面的代码,我可以获得web票证值和UCWA基本URL (通过自动发现),然后到镇上查询API。这不是最漂亮的代码,但有效。
注释:,您需要在中添加对托管DLL的引用。对我来说,这意味着:
Credentials.dllLyncConnectivityAnalyzer.Logging.dllLyncConnectivityAnalyzer.Resources.dllLyncWebServices.dllUtilities.dll您还需要将非托管‘ll复制到与应用程序(例如\bin\文件夹)相同的文件夹中(可能只有一个,但两者我都做了)。
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;
}
}
}https://stackoverflow.com/questions/25093344
复制相似问题