nmarus / node-ews

A simple JSON wrapper for the Exchange Web Services (EWS) SOAP API.
MIT License
116 stars 52 forks source link

Cannot login to exchange server #26

Closed jwcrawley closed 8 years ago

jwcrawley commented 8 years ago

Greetings,

When I put in my credentials in the variables for this service, and then attempt to run the script, I get a NTLMStatusCode: 401 Unauthorized.

If I instead go to https://[SERVER]/EWS/Exchange.asmx in the browser , it prompts me for a login/password. It accepts my credentials, and then sends me to a page with a link to a .wsdl, the text "You have created a service." and some C#/VB code.

Is this related to the plain text issue others have been having? Or is this me missing something blindingly obvious?

Sincerely, Josh

nmarus commented 8 years ago

Unauthorized 401 is typically related to the format of the username. I am using [username] for the Exchange server I am connecting to. A few things that might be the cause:

aaroncalderon commented 8 years ago

I am now getting the same error as @jwcrawley. It is odd, since it was working yesterday, but its not today.

I was using the form of [username]@[domain-name] successfully.

Since I started getting the error I have been using all kinds of forms with no avail.

May have the system admins changed something that is causing my account to get denied access to the exchange services?

Update

I kept trying and I went back to using the original [username]@[domain-name] pattern. I did, however, changed the variables to another file and I include it on my scripts.

var conf = require('./config/config')

config.js

module.exports = {
      username: 'username'
    , password: 'Secret'
    , host: 'https://exchange.sameple.com'
};

So, I attribute my issue to my username being mispelled.

Althoug I still wonder if something else was causing the NTLM StatusCode: 401 Unauthorized. issue.

eino-makitalo commented 8 years ago

I have this very same issue with Exchange 2007 SP3... no ntlm login what ever I try. Does this support NTLMv2?

eino-makitalo commented 8 years ago

I got it working with process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; and then

var username = 'user@example.local';
var password = 'xxxx';
var host = 'https://localhost';
eino-makitalo commented 8 years ago

To clarify my problem. I had a tunnel with ssh from localhost to Exchange Server 2007 SP3 and I found out that it gave all the time 401 Unathorize when I had also options in use

var options = {
 **rejectUnauthorized: false,**
 strictSSL: false
};

If you want to use options, take away rejectUnauthorized. I removed 4th parameter options away and found out that process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; was enough. If I used rejectUnauthorized (true or false) I got 401 Unauthorized error all the time

I think this is because NTLM negotiation send 401 in the beginning and after type1 message. So it should continue to work. Code seems to set rejectUnauhtorized=true before type3 message which is OK. Before that, it's normal in protocol to get 401 error.

nmarus commented 8 years ago

Updated documentation for this in v3.0.0