Link to home
Start Free TrialLog in
Avatar of Richard M.
Richard M.

asked on

Integrated Windows authentication using AJAX in an html page.

I am trying to write a Javascript using AJAX to get and send the windows credentials to the server app for integrated windows authentication and have a web page returned that represents the roles of the user.  I am using red hat developer studio and wildfly 15.  I am tackling this one thing at a time.  The first step is to send the credentials.  This is what I have so far.  I am pretty new at developing, so I would appreciate any feedback.  I know I am missing the script tag to start it.  There are other things that are not relevant, so I did not include them.

var service_url = ""
    type: "GET",
    url: service_url,
    dataType: "xml",
    data: "ParamId=" + FormId.value,
    processData: false,
    beforeSend : function(req) {
               make_base_auth ('USERNAME', 'PASSWORD'));
    error: function(XMLHttpRequest, textStatus, errorThrown) {  
         ajaxError(XMLHttpRequest, textStatus, errorThrown);
    success: function(success); }
    function success()
    {<alert SUCCESS!> }
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Hi Richard,

Looks like this is your first question - welcome to EE.

Just trying to understand what it is you are looking for?

Does your code not work?

Can you give us some more information about what you are expecting and what you are observing.
Avatar of Richard M.
Richard M.


To tell you the truth, I have not been able to ascertain whether or not the code is working.  The beginning part of the script sets up some text and a button and tells the user to press the button to authenticate.  When I press the button, the success function does not seem to be working.  After some thought I realize I have not built the server app to handle the request yet, but I also am not getting an error message.  Is there a way to test whether or not my script is working?
Your script is setup to make an AJAX call to a server resource so there are two sides to this equation - a working solution is when both sides are doing what they are supposed to do.

Before looking at the AJAX side it is important to determine if your server code is working.

Your URL points to
That suggests that there is some code on the end of that link that is going to return some XML.

From your second post it sounds like you have jumped in the deep end so let's go back to the beginning.

Is this code you have written or did you copy it from somewhere?
What are you expecting it to do?
Would it be helpful to go through it line by line to break it down or are you ok with what it is doing?
I think I have an understanding of what it is supposed to be doing.  I copied a bulk of the code, then changed it (hopefully correctly) for my environment.

I am expecting the code to get the windows credentials from the logged on user and then request the xml files with the auth information.

If that is not correct, I am happy to accept critiques, etc.
The JavaScript code has nothing to do with windows. All it is doing is calling a URL and then responding to the content returned from that URL.

The key is what is at the other end of that URL.

On return the code does nothing - so unless the purpose is to change state on the server AND there is a script listening on the script does not do anything.
So you are saying that it does not collect the IWA credentials?  I think I am just going to start from scratch.
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much.  I will try this.  I am marking it as the answer.  I really appreciate your help.
You are welcome.
Thank you very much for your help.  I believe I have it now and am working on the server side for authenticating the user to the application.
again you are most welcome.