Solved

NTLM in ajax calls

Posted on 2014-04-23
8
2,018 Views
Last Modified: 2014-05-03
Hi Experts,

I just noticed that the browser doesn't take over the 401 responses that we get in ajax when NTLM is expected with the server.  To be more precise - it looks like I need to implement NTLM in ajax myself?  Is there an easy way to do this?

Thanks!
Mike
0
Comment
Question by:thready
  • 5
  • 3
8 Comments
 
LVL 37

Expert Comment

by:bbao
ID: 40019369
Ajax is not a single technology, but a group
of technologies of HTML, CSS, DCOM and JavaScript to dynamically display for and interact with users. sepcifically, JavaScript and the XMLHttpRequest object provide a method for exchanging data asynchronously between browser and server to avoid full page reloads.

therefore, basically NTLM has nothing to do Ajax itself, it may be related to HTTP request if NTLM authentication is required.

if the web server is IIS, you may enable Integrated Windows Authentication to allow NTLM authentication over HTTP. from Ajax programming side, nothing you can do specifically for NTLM authentication.

however, be aware although you won't be exposing credentials in cleartext using NTLM over HTTP, you will be exposing everything else, so the afterward HTTP traffic won't be secure from confidentiality or integrity breaches.
0
 
LVL 1

Author Comment

by:thready
ID: 40020373
Well, I've implemented NTLM in an http server.  It works fully when you navigate to a site it serves up when you enter the site on the browser address field.  But when you make similar requests through xhr (which also happen to be cross domain), they don't authenticate.

I'm going to see if non-cross domain calls will authenticate first to see if it's something to do with the CORS headers.
0
 
LVL 1

Author Comment

by:thready
ID: 40020376
By the way, the CORS code worked fine before I added the NTLM functionality to the server...
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 37

Expert Comment

by:bbao
ID: 40020436
> Well, I've implemented NTLM in an http server.

on an IIS website over HTTP? is the IIS a member of domain?

> when you make similar requests through xhr (which also happen to be cross domain), they don't authenticate.

in my understanding, for NTLM authentication, basically it depends on the NTFS permissions of the pages/files to allow or deny the users' HTTP requests. therefore, for requests across domain, they will be denied as the files on NTFS not permitted to be accessed.
0
 
LVL 1

Author Comment

by:thready
ID: 40020486
But it's not IIS - it's our own web server code from an open source project (C# webserver)...  Which does work for normal browser address bar style requests...
0
 
LVL 37

Expert Comment

by:bbao
ID: 40020524
> Well, I've implemented NTLM in an http server.
>> But it's not IIS - it's our own web server code ...

your "implemented" does mean "implemented", i thought it just meant "deployed". :-))

where are the web pages physically located? still on a NTFS partition of Windows?
0
 
LVL 1

Accepted Solution

by:
thready earned 0 total points
ID: 40026039
I figured it out- the server side code did handle normal address bar requests because the browser implements that.  However, it seems the browser does go through entirely different code when calls come from ajax - particularly calls from ajax that are cross domain.  The solution was to add the correct server side headers for CORS and in addition, use the extra parameter in ajax stating, "use-credentials" if I remember correctly.  Very tricky actually - at the very least - 3 separate variables preventing all this from working in the normal way...

Thanks for trying - there was a lot more involved than I described in my question- the cost of trying to pinpoint problems...
0
 
LVL 1

Author Closing Comment

by:thready
ID: 40039039
It's the solution!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Compute age Html 2 24
DNS/WINS in a domain 10 42
What is the correct way to check for empty value in input field 2 16
HTML editor custom button 3 57
A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question