Wednesday, October 31, 2018

Exchange Server Version



            string exchangeVersion = "";
            exchangeVersion = OwaTools.GetExchangeServerVersion("foo.bar@outlook.com", "pwd", "https://outlook.office365.com/EWS/Exchange.asmx");


using Microsoft.Exchange.WebServices.Data;


        /// <summary>
        /// gets Exchange Server Version
        /// </summary>
        /// <param name="userName">Domain\Username or email adress in some cases (office365)</param>
        /// <param name="userPassword">pwd</param>
        /// <param name="uri">https://server/EWS/EWS/Exchange.asmx e.g. https://outlook.office365.com/EWS/Exchange.asmx  </param>
        /// <returns></returns>
        public static string GetExchangeServerVersion(string userName, string userPassword, string uri)
        {
            var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
            service.Credentials = new NetworkCredential(userName, userPassword);
            service.Url = new Uri(uri);
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; // ignore invalid or self signed certificates
            var inbox = Folder.Bind(service, WellKnownFolderName.Contacts);
            var esi = inbox.Service.ServerInfo;
            return esi.VersionString;
        }

1 comment:

jamesfo8376 said...

That is the best blog for anybody who wants to seek out out about this topic. You realize so much its virtually onerous to argue with you (not that I actually would want…HaHa). You positively put a new spin on a topic thats been written about for years. Nice stuff, simply great! casino games