Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
Posts: 3
Registered: ‎12-26-2013
My Device: blackberry
My Carrier: blackberry

Request data with NTLM authentication by using ajax on blackberry

Hi,

I want to connect to the server which supports NTLM authentication, and I'm using the following code snippet to request data:

 

$.ajax({
  url: url,
  type: 'get',
  dataType: 'jsonp',
  jsonpCallback: jsonpCallback,
  contentType: "application/json;charset=utf-8",
  beforeSend: function (xhr) {
    xhr.setRequestHeader("Authorization", "Basic " + btoa('AD-ENT\\' + u + ":" + p));
  },
  success: successCallback,
  error: function (XMLHttpRequest) {
    if (XMLHttpRequest.status == 401) {
      alert("Authentication Failed");
    }
  },
  complete: function (XMLHttpRequest) {
      ....
  }
});

 

But when invoking this code, following authentication dialog popup:

 


It seems like it is not effective to request data with authentication.

So did anyone know this issue and can help me?
How to supress the browser's authentication dialog?
How to request data with NTLM authentication by using ajax request?
Thanks very much.

Developer
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: Request data with NTLM authentication by using ajax on blackberry

Looking at your code, it seems like your setRequestHeader() call is requesting basic authentication, not NTLM. 

 

It might be helpfull to note whether your app connects over the plain-old-internet or over a BES connection.

 

For regular internet connections, this may help:

https://github.com/erlandranvinge/ntlm.js

 

For BES/MDS, it should be handled by the server on the users behalf.

 

But please remember that you really shouldn't be using NTLM anymore. It's outdated, insecure if used incorrectly and not compatible with modern standards. Even Microsoft agrees.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Highlighted
New Developer
Posts: 3
Registered: ‎12-26-2013
My Device: blackberry
My Carrier: blackberry

Re: Request data with NTLM authentication by using ajax on blackberry

Thanks @Innovatology

 

We've tried the ntlm.js library and it should be a correct solution.

 

But we find it's using ajax request to access the NTLM authentication, and our authentication or request url is cross-domain. You can find the dataType of data we are geting is jsonp.