Solved

NTLM in ajax calls

Posted on 2014-04-23
8
1,905 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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 …
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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…

777 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