Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Basic Auth alongside with NTLM #157

Closed
guderkar opened this issue Feb 7, 2017 · 2 comments
Closed

Use Basic Auth alongside with NTLM #157

guderkar opened this issue Feb 7, 2017 · 2 comments

Comments

@guderkar
Copy link

guderkar commented Feb 7, 2017

Hi, I need to authenticate either with Basic Auth or NTLM, because I don't know if server will be using Basic or NTLM or both. So I just set the exch.XHRApi property.

var ntlmXHR = require("./ntlmXHRApi");
var ntlmXHRApi = new ntlmXHR.ntlmXHRApi(username, password);
var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2007);
exch.Credentials = new ews.ExchangeCredentials(username, password);
exch.Url = new ews.Uri(URL);
exch.XHRApi = ntlmXHRApi;

exch.FindFolders(ews.WellKnownFolderName.Root, new ews.FolderView(1)).then(function (response) {
	process.stdout.write("OK");
        process.exit(0);
}, function (error) {
	process.stdout.write("ERROR");
	process.exit(1);
});

When only NTML is enabled on the server it's working fine.
When NTLM + Basic Auth is enabled it's also working fine.
But when only Basic Auth is enabled I get: TypeError: Cannot set property 'getAllResponseHeaders' of undefined.
Is there some workaround for this?

@gautamsi
Copy link
Owner

gautamsi commented Feb 7, 2017

Authentication has to be configured per server, means you can call with ntlm or basic auth support but not both. there is a way to figure this out. You can call EWS with random data, it will come back with response header with what type of authentication is supported, look for WWW-Authenticate header, if it contains Basic word, you do not need to wire up any authentication.

once i publish update to Autodiscover, you can then use correct way to determine authentication.

You may also try ews-javascript-api@next npm package with ews-javascript-api-auth package, which simplifies authentication.

@gautamsi
Copy link
Owner

gautamsi commented Jul 1, 2017

have you checked out #180 this will help your scenario. Also published in 0.9.0 final.

@gautamsi gautamsi closed this as completed Jul 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants