EWS connect to ExchangeServer authentication specifications
- by dankyy1
Hi all
I'm connecting to ExchangeServer with username,password,doain properities(my code below)
but what how to define server uses Kerberos,ntlm or basic authentication e.g?
thnx
xchangeServiceBinding binding = new ExchangeServiceBinding();
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
System.Net.WebProxy proxyObject = new System.Net.WebProxy();
proxyObject.Credentials = System.Net.CredentialCache.DefaultCredentials;
if (string.IsNullOrEmpty(credentials.UserName) || string.IsNullOrEmpty(credentials.Password) || string.IsNullOrEmpty(credentials.Domain))
throw new ArgumentNullException("The Crediantial values could not be null or empty.");
binding.Credentials = new NetworkCredential(credentials.UserName, credentials.Password, credentials.Domain);
if (string.IsNullOrEmpty(serverURL))
throw new ArgumentNullException("The Exchange server Url could not be null or empty.");
binding.Url = serverURL;
binding.UseDefaultCredentials = true;
binding.Proxy = proxyObject;
//TO DO:take version over parameter..or configration!!
binding.RequestServerVersionValue = new RequestServerVersion();
binding.RequestServerVersionValue.Version = (ExchangeVersionType)Enum.Parse(typeof(ExchangeVersionType), serverVersion);// ExchangeVersionType.Exchange2007_SP1;//.Exchange2010;