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

Autodiscovery not working from example #90

Closed
snollygolly opened this issue Aug 17, 2016 · 5 comments
Closed

Autodiscovery not working from example #90

snollygolly opened this issue Aug 17, 2016 · 5 comments

Comments

@snollygolly
Copy link
Contributor

I'm using the code from the example for autodiscovery, but it doesn't look to be working correctly. My code is as follows:

//import ews module
var util = require('util');
var ews = require('ews-javascript-api');
//create AutodiscoverService object
var autod = new ews.AutodiscoverService(new ews.Uri("https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc"), ews.ExchangeVersion.Exchange2016);
//you can omit url and it will autodiscover the url, version helps throw error on client side for unsupported operations.example - //var autod = new ews.AutodiscoverService(ews.ExchangeVersion.Exchange2016);
//set credential for service
autod.Credentials = new ews.ExchangeCredentials("email@domain.net", "password");
//create array to include list of desired settings
var settings = [
ews.UserSettingName.InternalEwsUrl,
ews.UserSettingName.ExternalEwsUrl,
ews.UserSettingName.UserDisplayName,
ews.UserSettingName.UserDN,
ews.UserSettingName.EwsPartnerUrl,
ews.UserSettingName.DocumentSharingLocations,
ews.UserSettingName.MailboxDN,
ews.UserSettingName.ActiveDirectoryServer,
ews.UserSettingName.CasVersion,
ews.UserSettingName.ExternalWebClientUrls,
ews.UserSettingName.ExternalImap4Connections,
ews.UserSettingName.AlternateMailboxes
];
//get the setting
autod.GetUserSettings(["email@domain.net"], settings)
.then(function (response) {
    //do what you want with user settings
    var tabcount = 0;
    var tabs = function () { return ews.StringHelper.Repeat("\t", tabcount); };
    console.log(autod.Url.ToString());
    //uncoment next line to see full response from autodiscover, you will need to add var util = require('util');
    console.log(util.inspect(response, { showHidden: false, depth: null, colors: true }));
    for (var _i = 0, _a = response.Responses; _i < _a.length; _i++) {
        var resp = _a[_i];
        console.log(ews.StringHelper.Format("{0}settings for email: {1}", tabs(), resp.SmtpAddress));
        tabcount++;
        for (var setting in resp.Settings) {
            console.log(ews.StringHelper.Format("{0}{1} = {2}", tabs(), ews.UserSettingName[setting], resp.Settings[setting]));
        }
        tabcount--;
    }
}, function (e) {
    //log errors or do something with errors
});

I'm seeing the following in my console:

sending ews request
{ type: 'POST',
  data: '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Header><a:RequestedServerVersion>Exchange2016</a:RequestedServerVersion><wsa:Action>http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetUserSettings</wsa:Action><wsa:To>https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc</wsa:To></soap:Header><soap:Body><a:GetUserSettingsRequestMessage xmlns:a="http://schemas.microsoft.com/exchange/2010/Autodiscover"><a:Request><a:Users><a:User><a:Mailbox>email@domain.net</a:Mailbox></a:User></a:Users><a:RequestedSettings><a:Setting>InternalEwsUrl</a:Setting><a:Setting>ExternalEwsUrl</a:Setting><a:Setting>UserDisplayName</a:Setting><a:Setting>UserDN</a:Setting><a:Setting>EwsPartnerUrl</a:Setting><a:Setting>DocumentSharingLocations</a:Setting><a:Setting>MailboxDN</a:Setting><a:Setting>ActiveDirectoryServer</a:Setting><a:Setting>CasVersion</a:Setting><a:Setting>ExternalWebClientUrls</a:Setting><a:Setting>ExternalImap4Connections</a:Setting><a:Setting>AlternateMailboxes</a:Setting></a:RequestedSettings></a:Request></a:GetUserSettingsRequestMessage></soap:Body></soap:Envelope>',
  url: 'https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc',
  headers: 
   { 'Content-Type': 'text/xml',
     Authorization: 'Basic bWF...SE=' } }
https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc
undefined

Any thoughts on why it's showing undefined?

@gautamsi
Copy link
Owner

unfortunately it does not give descriptive errors, I am working on fixing the AutoDiscover error part.

can you verify you are using correct email address for lookup, it is known issues per #23. I have tested this myself and it was working for me.

@snollygolly
Copy link
Contributor Author

I'm positive I have the correct email address (I'll PM it to you in Gitter).

I'm using Exchange 2016, hosted in the cloud by Rackspace if that helps.

@gautamsi
Copy link
Owner

what is the authentication used by Rackspace? basic or NTLM. can you test AutoDiscover with https://testconnectivity.microsoft.com/

@snollygolly
Copy link
Contributor Author

I believe it's NTLM.

I tested "Outlook Autodiscover" (I think that's the right one, if not, I'll test another) and it passed.

screen shot 2016-08-17 at 1 11 33 pm

@gautamsi
Copy link
Owner

ntml related code is fixed in #94

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