From 83070f445eaa3f12d380846b6002260279e9f54b Mon Sep 17 00:00:00 2001 From: Roman Maksimov Date: Mon, 3 Feb 2020 06:06:28 +0300 Subject: [PATCH] add ExHTTP provider and Negotiate authentication scheme support --- autodiscover/autodiscover.go | 38 ++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/autodiscover/autodiscover.go b/autodiscover/autodiscover.go index 23c4401..a1c5d9e 100644 --- a/autodiscover/autodiscover.go +++ b/autodiscover/autodiscover.go @@ -117,18 +117,40 @@ func GetRPCHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils. url := "" user := "" ntlmAuth := false + firstExHTTPResp := true for _, v := range resp.Response.Account.Protocol { - if v.Type == "EXPR" { - if v.SSL == "Off" { - url = "http://" + v.Server - } else { - url = "https://" + v.Server - } - if v.AuthPackage == "Ntlm" { //set the encryption on if the server specifies NTLM auth - ntlmAuth = true + // use the first available Outlook provider and skip the others + if url == "" { + // ExHTTP (Exchange 2013+) + // the first ExHTTP answer is for internal Outlook clients + // and the second one is for external Outlook clients + // EXPR (Exchange 2007/2010) is for external Outlook clients + if v.Type == "EXHTTP" || v.Type == "EXPR" { + if v.Type == "EXHTTP" { + // skip the first answer + if firstExHTTPResp == true { + firstExHTTPResp = false + continue + } + } + if SessionConfig.Verbose == true { + utils.Trace.Printf("%s provider was selected", v.Type) + } + if v.SSL == "Off" { + url = "http://" + v.Server + } else { + url = "https://" + v.Server + } + if v.AuthPackage == "Ntlm" || v.AuthPackage == "Negotiate" { //set the encryption on if the server specifies NTLM or Negotiate auth + if SessionConfig.Verbose == true { + utils.Trace.Printf("Authentication scheme is %s", v.AuthPackage) + } + ntlmAuth = true + } } } + // EXCH (Exchange 2007/2010) is for internal Outlook clients if v.Type == "EXCH" { user = v.Server }