2

I'm working on a UWP project. I want to get the access token for the current user.

In another thread I found that there's no available LDAP/AD API in a WinRT app. When searching for more I found that there is Microsoft.IdentityModel.Clients.ActiveDirectory which enables developers to easily authenticate users to cloud or on-premises Active Directory (AD).

But I can't find any documentation or samples to authenticate a UWP app with an internal corporate AD infrastructure. Does somebody have some more information on how this would be accomplished?

SilentStorm
  • 172
  • 1
  • 1
  • 12
Y Mor
  • 41
  • 5
  • What's the question ? Are you asking for documentation ? – Marcs Nov 29 '16 at 15:22
  • How about using AuthenticationContext.AcquireToken group of methods. Are there any tests you made with this? – VitaliyK Nov 29 '16 at 15:26
  • the question is if there are any docs or samples for using **Microsoft.IdentityModel.Clients.ActiveDirectory** to authenticate with the internal Active directory – Y Mor Nov 29 '16 at 15:40

2 Answers2

1

Since the original question is a little bit unclear, I am assuming you're asking for samples.

Adal (Active Directory Authentication Library) is indeed the way to go. As I am confronted with the same problem I share your frustrations in this.

However, code samples are available (according to MSDN):

https://learn.microsoft.com/en-us/azure/active-directory/active-directory-code-samples

https://learn.microsoft.com/en-us/azure/active-directory/active-directory-authentication-libraries

Instead of returning your token from an Azure AD you call ADFS on your server which will return the auth token. A little tutorial here how to setup ADFS. Whenever they talk about tenants in my previous examples they're talking about your on-premise AD. (it's Azure talk)

Please look at this answer it should provide some more insight (and code).

Community
  • 1
  • 1
SilentStorm
  • 172
  • 1
  • 1
  • 12
  • thank you for the reply but i want samples or docs for internal AD not Azure AD – Y Mor Nov 29 '16 at 15:36
  • **The Azure AD authentication Library (ADAL) enables client application developers to easily authenticate users to cloud or on-premises Active Directory (AD)** first sentence on the website, on-premises is what you wanted right? Don't be confused by their naming. – SilentStorm Nov 29 '16 at 15:40
  • yes and for now i couldn't find any doc to use **ADAL** on a **on-permises** **AD** – Y Mor Nov 29 '16 at 21:21
  • I think you're confused, there is not much difference: you request an Oauth token from a server by passing the right uri and credentials. Updated answer with some more examples. Like @Kanishk Panwar - MSFT Mentioned: there is no way you can query ldap like in WPF for example. for the small differences, look at the last asnwer i posted, someone already figured it out. – SilentStorm Nov 30 '16 at 12:55
0

Adal is not a LDAP/AD library. It speaks oauth2 and it will work as long as you have a version of ADFS that is capable of speaking oauth2.

Kanishk Panwar
  • 1,105
  • 8
  • 7
  • What details are you looking for? ADAL can authenticate the users that are in Azure Active Directory or an on-premise active directory. See http://blog.scottlogic.com/2015/03/09/OAUTH2-Authentication-with-ADFS-3.0.html – Kanishk Panwar Nov 29 '16 at 22:40