NodeSSPI icon indicating copy to clipboard operation
NodeSSPI copied to clipboard

Sending request to nodeSSPI on a remote server via XHR?

Open BrianJVarley opened this issue 8 years ago • 3 comments

@abbr I added the nodeSSPI Api call to an express server on a remote machine. Everything works fine on a local host request via Ajax from the browser and the user's name is returned from req.connection.user;

But when I deploy the express server to a remote machine outside our domain. The server denies the GET request from the browser to the nodeSSPI Api on the express server -app.get('/OOO/UserLDAP', UserLDAP.Authenticate); giving back a 401 error-

Failed to load resource: the server responded with a status of 401 (Unauthorized)

Do I need to pass basic auth credentials in the xhr request in order for nodeSSPI Api to return NT name? As I said the 401 only returns when I move the express server to another domain machine.

Or can the NT user name be retrieved from the API without passing the credentials in the request header?

In my case I just need the user's NT login name to pass onto another internal LDAP request server. This is a gist of my express server's setup as is:

https://jsfiddle.net/brianVarley/tf1puukp/

BrianJVarley avatar Nov 21 '16 17:11 BrianJVarley

i have the same issue but both of my machines are on the same domain. requests to localhost authenticate as expected, but remote requests are prompted for basic auth and are rejected regardless if a correct password is supplied.

zcmack avatar Nov 22 '16 20:11 zcmack

@zcmack Yes same today I changed my solution to setCredentials=true in the XHR request. Which in turn prompts for basic auth when I send a request to the remote express server. Supplying the correct credentials to the basic auth pop up are rejected. Thus giving back the 403.

In contrast with that when I send the request to the server run on local the basic auth popup accepts my credentials and returns expected Json result.

Hoping to hear something back on here as to why this doesn't work when deployed to a remote server. :)

BrianJVarley avatar Nov 22 '16 21:11 BrianJVarley

Is primary web page's host name same as xhr's?

abbr avatar Nov 24 '16 04:11 abbr