Properly Establishing an ApplicationEndpoint in UCMA 3.0 - proxy

I've been struggling with getting an application endpoint working on UCMA 3.0. I am trying to run an application on a server separate from the Lync server which uses a registered ApplicationEndpoint to monitor presence and act as a bot which can send other users messages. I used to have my code working with a UserEndpoint (which was fine for monitoring presence), but did not have the capabilities to send IMs to other Lync users.
After searching the web, I'm finally at the point where I'm getting this error when running my code:
System.ArgumentException was unhandled
Message=An ApplicationEndpoint can be registered only if proxy and Multual Tls have been specified.
Source=Microsoft.Rtc.Collaboration
StackTrace:
at Microsoft.Rtc.Collaboration.ApplicationEndpoint..ctor(CollaborationPlatform platform, ApplicationEndpointSettings settings)
at Waldo.endpointHelper.CreateApplicationEndpoint(ApplicationEndpointSettings applicationEndpointSettings) in C:\Users\l1m5\Desktop\waldoproject\trunk\WaldoSoln\waldoGrabPresence\endpointHelper.cs:line 117
at Waldo.endpointHelper.CreateEstablishedApplicationEndpoint(String endpointFriendlyName) in C:\Users\l1m5\Desktop\waldoproject\trunk\WaldoSoln\waldoGrabPresence\endpointHelper.cs:line 228
at Waldo.waldoGrabPresence.Run() in C:\Users\l1m5\Desktop\waldoproject\trunk\WaldoSoln\waldoGrabPresence\waldoGrabPresence.cs:line 60
at Waldo.waldoGrabPresence.Main(String[] args) in C:\Users\l1m5\Desktop\waldoproject\trunk\WaldoSoln\waldoGrabPresence\waldoGrabPresence.cs:line 42
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
After some searching, I followed the instructions here: http://blogs.claritycon.com/blogs/michael_greenlee/archive/2009/03/21/installing-a-certificate-for-ucma-v2-0-applications.aspx to import a certificate onto the server that I'm trying to run the application on, but to no avail.
So at this point, I think that there must be something wrong with how I'm setting up the ApplicationEndpointSettings, CollaberationPlatform or ApplicationEndpoint objects. Here's how I'm doing it:
ApplicationEndpointSettings settings = new ApplicationEndpointSettings(_ownerURIPrompt, _serverFQDNPrompt, _trustedPortPrompt);
ServerPlatformSettings settings = new ServerPlatformSettings(null, _serverFQDNPrompt, _trustedPortPrompt, _trustedApplicationGRUU);
_collabPlatform = new CollaborationPlatform(settings);
_applicationEndpoint = new ApplicationEndpoint(_collabPlatform, applicationEndpointSettings);
Does anyone see any problems with what I'm doing? Or, better yet, does anyone know of a blog that walks you through establishing an application endpoint in the situation I'm in? I work really well with tutorials or samples, but have not found one that seems to accomplish what I'm trying to do.
Thanks for the help!

The procedure to get a certificate in Lync is very different than OCS2007, and much easier. The link you posted is for UCMA2, and OCS, I believe. In Lync, it's basically two powershell statements.
1) Request-CSCertificate -Action new -Type default -CA -Verbose
2) Save the results of that statement, take the thumbprint, use it as the parameter to:
Set-CsCertificate -Type Default -Thumbprint XXXXXXXXXXXXXXXXXXXX
Installing UCMA 3.0 and Creating a Lync Server 2010 Trusted Application Pool

use powershell to provision a trusted application endpoint. The command to explore is new-trustedapplicationendpoint. The error you are getting is due to no trusted endpoint being registered, even though you may have your trusted application registered, it needs an endpoint to work and that endpoint must be first registered before you provision the platform.

The SDK CHM file should be your friend here! This section is about app activation and provisioning

Pass the certificate to the ServerPlatformSettings object, then it works. I had the similar problem, and the problem is resolved after using the ServerPlatformSettings(string applicationUserAgent, string localhost, int port, string gruu, string certificateIssuerName, byte[] certificateSerialNumber) constructor for the ServerPlatformSettings.

Related

Using HttpClient to access Web API issue (certificate?)

I have been following this link to understand how to use HttpClient to call a Web API Method.
https://www.tutorialsteacher.com/webapi/consuming-web-api-in-dotnet-using-httpclient
The code of interest in the article is below with ‘client’ being the HttpClient object:
client.BaseAddress = new Uri("http://localhost:60464/api/"); //HTTP GET
var responseTask = client.GetAsync("student");
responseTask.Wait();
var result = responseTask.Result;
Error results as follows:
System.AggregateException: 'One or more errors occurred. (Failed to connect to localhost/127.0.0.1:443)'
Please understand my background in networking, IIS and the like is very limited.Most of my time is spent in code and SQL Sprocs. This is a personal project so I have to get this setup myself
If I replace localhost with my machines IP I get the following error:
One or more errors occurred. (java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.)'
So two questions:
How do I install this needed certificate or settings or otherwise (again no idea about this configuration network stuff) but I do have IIS up and running with the Web API hosted and working
If using ‘localhost’ is not supposed to work, what might be the reason this article is using it?
This is only for a personal development machine, yes at some point I am going to want it to work in the real world but for now I just need to get some ‘hello world’ stuff going before the end of times.

Nuget.Server on Mac OSX

I followed this steps to setup my own nuget server on local machine (Mac)
https://learn.microsoft.com/en-us/nuget/hosting-packages/nuget-server
I got to step 6 and then when i click "here" it gives me the following error
System.Web.HttpException
The resource cannot be found.
Description: HTTP 404.The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Details: Requested URL: /nuget/Packages
Exception stack trace:
at System.Web.StaticFileHandler.ProcessRequest (System.Web.HttpContext context) [0x00094] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web/StaticFileHandler.cs:77
at System.Web.DefaultHttpHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback callback, System.Object state) [0x0007f] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web/DefaultHttpHandler.cs:101
at System.Web.HttpApplication+<Pipeline>d__225.MoveNext () [0x008d4] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web/HttpApplication.cs:1335
at System.Web.HttpApplication.Tick () [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System.Web/System.Web/HttpApplication.cs:927
Please help
I can see two issues in this approach.
Nuget.Server documentation mentions IIS as the web sever; IIS doesn't run on Mac OSX.
And, even if you end up using the native web server of your operating system, you will need WCF support in mono - which looks to be a work in progress.

Wifi WPS client start in Windows 10 in script or code

I can not find how to start WPS client in Windows 10 from command prompt or powershell. When I used Linux, everything was really ease with wla_supplicant (wpa_cli wps_pbc). Is there something similar in Windows?
Does anyone know how to set up Wi-Fi network (over WPS) key without human input in Windows?
I also tried WCN (Windows Connect Now) from Microsoft as it implements WPS features. I got also samples from Windows SDK on WCN, but they could not get key by WPS (it faild). But if I use Windows user interface to connect wiothout PIN, everyting seems to be pretty fine.
I am sure that there is possibility to do that, it is very important to perform Wifi Protected Setup by button start from the command prompt or app (C++/C#) without human intrusion or input (once WPS is on air, Windows should automatically get the network key and connect then).
I don't know if it's too late to answer, just put what I know in here and hope it can help.
First, if your system has updated to 16299(Fall Creator Update), you can just simply use new wifi api from UWP.
Install newest Windows SDK, create a C# console project, target C# version to at least 7.1, then add two reference to the project.
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd
After all of that , code in below should work.
using System;
using System.Threading.Tasks;
using Windows.Devices.Enumeration;
using Windows.Devices.WiFi;
class Program
{
static async Task Main(string[] args)
{
var dic = await DeviceInformation.FindAllAsync(WiFiAdapter.GetDeviceSelector());
if (dic.Count > 0)
{
var adapter = await WiFiAdapter.FromIdAsync(dic[0].Id);
foreach (var an in adapter.NetworkReport.AvailableNetworks)
{
if (an.Ssid == "Ssid which you want to connect to.")
{
// Fouth parameter which is ssid can not be set to null even if we provided
// first one, or an exception will be thrown.
await adapter.ConnectAsync(an, WiFiReconnectionKind.Manual, null, "",
WiFiConnectionMethod.WpsPushButton);
}
}
}
}
}
Build and run the exe, then push your router's button, your pc will be connect to the router.
But if you can not update to 16299, WCN will be your only choice. You may already notice that if call IWCNDevic::Connect frist with push-button method, the WSC(Wifi Simple Configuration) session will fail. That's because WNC would not start a push-button session as a enrollee, but only as a registrar. That means you have to ensure that router's button has been pushed before you call IWCNDevic::Connect. The way to do that is using Native Wifi api to scan your router repeatedly, analyse the newest WSC information element from the scan result, confirm that Selected Registrar attribute has been set to true and Device Password Id attribute has been set to 4. After that, query the IWCNDevice and call Connect function will succeed. Then you can call IWCNDevice::GetNetworkProfile to get a profile that can use to connect to the router. Because it's too much of code, I will only list the main wifi api that will be used.
WlanEnuminterfaces: Use to get a available wifi interface.
WlanRegisterNotification: Use to register a callback to handle scan an connect results.
WlanScan: Use to scan a specified wifi BSS.
WlanGetNetworkBsslist: Use to get newest BSS information after scan.
WlanSetProfile: Use to save profile for a BSS.
WlanConnect: Use to connect to a BSS.
And about the WSC information element and it's attributes, you can find all the information from Wi-Fi Simple Configuration Technical Specification v2.0.5.
For Krisz. About timeout.
You can't cast IAsyncOperation to Task directly. The right way to do that is using AsTask method. And also, you should cancel ConnectAsync after timeout.
Sample code:
var t = adapter.ConnectAsync(an, WiFiReconnectionKind.Manual, null, "",
WiFiConnectionMethod.WpsPushButton).AsTask();
if (!t.Wait(10000))
t.AsAsyncOperation().Cancel();

Connect to Oracle from Azure Web Role - empty error message

I't trying to port an existing web application to run as an Azure Web Role. This application uses Oracle DB, which I've installed on an Azure VM using one of the new Images available there.
The problem arises when I try to connect from the web application to the database. I'm able to connect to the database from my developer PC (from Visual Studio using ODBC) and I'm able to telnet to the port, so no firewall issues.
I'm using this technique: http://www.splinter.com.au/using-the-new-odpnet-to-access-oracle-from-c/ which has been described several places online, including here on StackOverflow. The only difference is that I use Oracle 12 instead of 11, and use the appropriate 64 bit libraries.
The error I get, is not very descriptive:
[OracleException (0x80004005)]
Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable) +1199
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src) +53
Oracle.DataAccess.Client.OracleConnection.Open() +4555
NHibernate.Connection.DriverConnectionProvider.GetConnection() +378
NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare() +92
NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper) +154
NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory) +312
NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) +1934
NHibernate.Cfg.Configuration.BuildSessionFactory() +292
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +54
[FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
]
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +111
MAP.NHibernateHelper.CreateSessionFactory() in C:\ProjectSVN\FluentWims\DataAccessLayer\DataMapping\NHibernateHelper.vb:102
MAP.NHibernateHelper.get_SessionFactory() in C:\ProjectSVN\FluentWims\DataAccessLayer\DataMapping\NHibernateHelper.vb:16
(Some lines deleted at the end as it contains some details I don't want to share publicly and I'm pretty sure they are irrelevant)
I've decompiled the managed code (OracleDataAccess.dll) and traced the problem to a call to this wrapped native call:
<DllImport("OraOps12.dll", EntryPoint:="OpsConOpen", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Unicode)> _
Public Shared Function Open(ByRef opsConCtx As IntPtr, ByRef opsErrCtx As IntPtr, ByRef pOpoConValCtx As OpoConValCtx, ByRef pOpoConRefCtx As OpoConRefCtx) As Integer
End Function
This returns -1, which isn't recognized as a known error code, and thus creates this exception which means next to nothing (at least not to me, even after googling like crazy ;)).
I have checked that if I remove OraOps12.dll, I get a different error message, and I've seen in ProcMon that the file is in fact found where I put it. I can find next to nothing about OraOps online, and what it means that this method returns -1.
Does anyone know what might be going on here, and what might be wrong?
UPDATE
I've tried to look with a network monitor, at what is being sent to the oracle database, and I can't find any traffic - so OraOps seems to be called, but it doesn't get as far as to try to communicate with the database server.
The connection string I'm using, is copy/paste from the working connection in Visual Studio, so I assume it is correct. Even if it wasn't, I would expect a more descriptive error message back...

Sharepoint 2010 Client Object Model Remote Access via HTTPS

I was encouraged to learn that the Sharepoint 2010 Client Object Model essentially wraps remote calls to the server. So, I copied the Microsoft.Sharepoint.Client.Silverlight.dll and Microsoft.Sharepoint.Client.Silverlight.Runtime.dll from my Sharepoint 2010 server to my development machine (without Sharepoint). I assumed the Silverlight code I tested on the Sharepoint 2010 server would also work on my development machine. Naturally, I don't use the "ApplicationContext.Current.Url" because I am not executing in Sharepoint, so I manually add sharepoint server name as follows (kept anonymous for the post):
//ClientContext context = new ClientContext(ApplicationContext.Current.Url);
ClientContext context = new ClientContext("https://[servername]");
_web = context.Web;
context.Load(_web);
context.Load(_web.Lists);
context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler (OnRequestSucceeded), new ClientRequestFailedEventHandler(OnRequestFailed));
When I execute the code, I am prompted by a Windows Authentication window (Sharepoint is configured to use Windows Authentication), I add my domain/user and password. However, I am getting the following error:
Note: I was able to get Sharepoint 2010 web services working given a similar error by changing the binding security mode="Transport" and including a clientAccessPolicy.xml file on the Sharepoint root website. Do I need to configure another Sharepoint directory for thje Client Object Model endpoint?
Exception {System.Security.SecurityException ---> System.Security.SecurityException: Security error.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryGetResponseAsyncCallback(IAsyncResult asyncResult)} System.Exception {System.Security.SecurityException}
Please look in to the below blog post, you need to add clientaccesspolicy.xml file in your sharepoint website root folder.
http://vangalvenkat.blogspot.com/2011/08/sharepoint-2010-getting-list-item.html
Aha, I found it. You can set the security on the client context to use the default windows authentication like so:
using (Microsoft.Sharepoint.Client.ClientContext ctx = new Microsoft.Sharepoint.Client.ClientContext("http://sharepointserver")){
ctx.AuthenticationMode = Microsoft.Sharepoint.Client.ClientAuthenticationMode.Default
}
This should also prevent any windows authentication pop-ups

Resources