Search code examples
iosadaladfs3.0

Is ADAL for iOS compatible with ADFS version 3.0?


I'm using AzureAD Library for Objective-C (https://github.com/AzureAD/azure-activedirectory-library-for-objc) to connect to ADFS 3.0 on 2012 R2 using the OAuth 2 Authorization Code grant flow.

I'm getting the error:

Error with code: AD_ERROR_DEVELOPER_INVALID_ARGUMENT 
Domain: ADAuthenticationErrorDomain ProtocolCode:(null) 
Details:The argument 'user principal name' is invalid. 
Value:(null). 
Inner error details: Error Domain=ADAuthenticationErrorDomain Code=100 "(null)"

We have an android app that is connecting successfully, so I don't think this is the real error.

I'm using v2.6.3 of the library on iOS 11.3, both on an iPhone 6 and on the simulator with the same results.

I'm reproduced the issue using the SampleSwiftApp included with the repo, with no code changes apart from the configuration.

  • Is v2.6.3 compatible with ADFS v3.0 on 2012 R2?
  • Can I get it to work with a configuration change?

Solution

  • ADFS v3.0 doesn't support authority validation, so I updated the authentication context constructor from:

    let authContext = ADAuthenticationContext(authority: AdalAuthority,
                                              error: nil)
    

    to:

    let authContext = ADAuthenticationContext(authority: AdalAuthority,
                                              validateAuthority: false,
                                              error: nil)
    

    to get it to work.