Reputation: 605
I have a WPF application, and I'm following this tutorial: https://blogs.msdn.microsoft.com/dsnotes/2017/05/10/adal-secure-web-api-with-adfs-3-0-for-desktop-client/ to get WPF to authenticate with ADFS.
I have a button on the main page, and here's the code behind for the button click event handler:
string authority = "https://server1.mycompany.local/adfs";
string resourceURI = "https://localhost/MyWebAPIsample/";
string clientID = "bdf737f9-567a-4998-b5e5-500b9bc2d776";
string clientReturnURI = "https://arbitraryreturnuri/";
var authContext = new AuthenticationContext(authority, false);
var authResult = await authContext.AcquireTokenAsync(resourceURI, clientID, new Uri(clientReturnURI), new PlatformParameters(PromptBehavior.Auto));
At the last line var authResult = await ...
I get this error:
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: ' The browser based authentication dialog failed to complete. Reason: The request could not be processed by the server due to invalid syntax.'
and authentication_ui_failed
But, on the UI, I clearly see the authentication window popup and I can type in my AD credentials to log in. I've tried fixes from other posts, but I can't seem to figure out what's wrong. Is there anything blatantly wrong with my code or anything I should double check to figure out what's happening? I'm still new to AD, ADFS and ADAL libraries. Thank you!
Notes: I'm using Visual Studio 2017 with Windows Server 2016. I have a NodeJS backend but that's not relevant for this discussion I don't think.
Upvotes: 0
Views: 13415
Reputation: 605
I finally figured this problem out after a few hours of silly debugging. On another thread, I encountered a solution that said "enable forms authentication" and I checked and it was enabled, so I thought that's good. But, I had other items checked (again, I'm still new to ADFS) and that caused my system to not use forms authentication (which I couldn't tell - all I know was that I was typing in my AD user credentials). After deselecting all the other options, the authentication seemed slightly different from my original authentication window and worked.
Here are the steps on Windows Server 2016 to access "Authentication" explained like I'm five since that's my level of adfs understanding
Services
tab on the leftAuthentication Methods
and select Edit Primary Authentication Methods
Forms authentication
on both intranet and extranetUpvotes: 0