Atreidae / Get-CsUserLocation

Returns the user location as an object.
MIT License
0 stars 0 forks source link

Script unable to authenticate #3

Open vitalizm opened 6 years ago

vitalizm commented 6 years ago

I'm receiving an error "We couldn't AuthN with the username & password provided. Update and try again."

User is on-prem Lync 2013 Standard Edition environment.

One thing I've noticed is that the https://lyncdiscover.mydomain.com comes back with the "requesting URL" of the external DNS name of our Lync Director Pool which points to our reverse proxy.

vitalizm commented 6 years ago

Ok, the issue was on our side. The F5 reverse proxy didnt have a config to route requests to the director. The updated script helped to determine what the value the lyncdiscover came back with.

However, I do get an error creating the UCWA Application. "Unable to create application instance" -severity 4. Does the script need to be run in administrator mode?

Atreidae commented 6 years ago

The F5 reverse proxy didnt have a config to route requests to the director.

This would also have been stopping any mobile (or mac clients) on your LAN from authenticating correctly. See: http://blog.schertz.name/2013/11/lync-mobility-media-paths/

However, I do get an error creating the UCWA Application. "Unable to create application instance" -severity 4. Does the script need to be run in administrator mode?

No, the script is run entirely through the UCWA API so should not need admin rights You mentioned that your still running Lync 2013.. Mainstream support for Lync ends today. You should really consider upgrading to Skype for Business 2015.

I've published a new build #0.3 that you can download from here that should give us some additional insight into why the application request is failing.

You will need to run the script with the -verbose switch to see whats going on, or review the log file

Atreidae commented 6 years ago

Related to #1

vitalizm commented 6 years ago

We only have several Lync clients that run the Skype for Business client. The full Lync 2010 client work fine because they dont use the reverse proxy as they are the full client rather than web. Our plan is to migrate to Skype4B in the next few months.

Here is the output of the log (actual domain scrubbed):

LYNC13-01 date="04-11-2018" time="08:53:44" component="Self Update" type="1" Message="Checking for Script Update" LYNC13-01 date="04-11-2018" time="08:53:44" component="Self Update" type="1" Message="Checking for Proxy" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Checking for proxy settings" LYNC13-01 date="04-11-2018" time="08:53:44" component="Self Update" type="1" Message="No proxy setting detected, using direct connection" LYNC13-01 date="04-11-2018" time="08:53:44" component="Self Update" type="1" Message="Script is up to date on master branch" LYNC13-01 date="04-11-2018" time="08:53:44" component="Script Block" type="2" Message="Checking for Lync/Skype management tools" LYNC13-01 date="04-11-2018" time="08:53:44" component="Config" type="2" Message="Testing Autodiscover" LYNC13-01 date="04-11-2018" time="08:53:44" component="Config" type="1" Message="User defined url is " LYNC13-01 date="04-11-2018" time="08:53:44" component="Config" type="1" Message="Invoking webrequest" LYNC13-01 date="04-11-2018" time="08:53:44" component="Config" type="3" Message="Something went wrong getting to the AutoDiscover URL or the data was bad" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="2" Message="Attempting to download S4B Autodiscover Information" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Requesting URL https://lyncdiscover.domain.com" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Raw data {"_links":{"self":{"href":"https://lync13dir.domain.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=domain.com"},"user":{"href":"https://lync13dir1-ext.domain.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=domain.com"},"xframe":{"href":"https://lync13dir1-ext.domain.com/Autodiscover/XFrame/XFrame.html"}}}" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Found base url https://lync13dir1-ext.domain.com" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Found oauth url https://lync13dir1-ext.domain.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=domain.com" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="2" Message="Authenticating to Webservices to get oAuth Token" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Requesting URL https://lync13dir1-ext.domain.com/WebTicket/oauthtoken" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Oauth Returned" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="{"access_token":"cwt=AAEBHAEFAAAAAAAFFQAAAEKJ32ZsWDBwfI0vYzCbEgCBEPIKGYJ9acVegddMJSUWO0iCAkxfgyARZ1JB6GGRvmJmBkMk10mKh_MQbNzVbhxHbPlyriroSoYISyi7QwWg1QgNEKg4IwD-kIJamquuLslFuco","expires_in":27857,"ms_rtc_identityscope":"local","token_type":"Bearer"}.content" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Oauth Token cwt=AAEBHAEFAAAAAAAFFQAAAEKJ32ZsWDBwfI0vYzCbEgCBEPIKGYJ9acVegddMJSUWO0iCAkxfgyARZ1JB6GGRvmJmBkMk10mKh_MQbNzVbhxHbPlyriroSoYISyi7QwWg1QgNEKg4IwD-kIJamquuLslFuco" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="2" Message="Downloading application URLs" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Requesting URL https://lync13dir1-ext.domain.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=domain.com witha access token cwt=AAEBHAEFAAAAAAAFFQAAAEKJ32ZsWDBwfI0vYzCbEgCBEPIKGYJ9acVegddMJSUWO0iCAkxfgyARZ1JB6GGRvmJmBkMk10mKh_MQbNzVbhxHbPlyriroSoYISyi7QwWg1QgNEKg4IwD-kIJamquuLslFuco" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Raw data {"_links":{"self":{"href":"https://lync13-01-ext.domain.com/Autodiscover/AutodiscoverService.svc/root/user"},"applications":{"href":"https://lync13-01-ext.domain.com/ucwa/oauth/v1/applications"},"xframe":{"href":"https://lync13-01-ext.domain.com/Autodiscover/XFrame/XFrame.html"}}}" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Rootapp url returned https://lync13-01-ext.domain.com/ucwa/oauth/v1/applications" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="2" Message="Creating App Instance" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="1" Message="Requesting URL https://lync13dir1-ext.domain.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=domain.com witha application details { "UserAgent": "Get-CsUserLocation Version 0.3", "Culture": "en-US", "EndpointId": "d90347cd-31b9-4cd7-9abe-7814fe52c43b" }" LYNC13-01 date="04-11-2018" time="08:53:44" component="Default" type="4" Message="Unable to create application instance"

Atreidae commented 6 years ago

It looks like its failing the web request to the frontend, or thats returning an error code. Judging by the host name I see your running this from the frontend. Can you try from another machine? feel free to comment out the Lync tool requirement check

Otherwise run the script in an ISE window.. then after the failure. run these 2 cmdlets.

$data = Invoke-WebRequest -Uri "$rootappurl" -Method POST -Body "$postparams" -Headers @{"Authorization"="Bearer $authcwt"} -ContentType "application/json" -UseBasicParsing

write-output $data

vitalizm commented 6 years ago

After running the two commands after the initial failure from a client machine, I get the following error "Invalid URI: The hostname could not be parsed."

I get the same error when running directly from the front end as well.