Connection problem with MS Exchange Server
-
Hi, I am trying to connect with Microsoft Exchange Server using the following code
static void Main(string[] args)
{ {System.Net.ServicePointManager.ServerCertificateValidationCallback =delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
};ExchangeServiceBinding objExchangeServiceBinding = new ExchangeServiceBinding();
objExchangeServiceBinding.Credentials = new System.Net.NetworkCredential("user", "pass", "domain.com");
//objExchangeServiceBinding.AllowAutoRedirect = true;
objExchangeServiceBinding.UseDefaultCredentials = true;
objExchangeServiceBinding.Url = "https://10.11.1.250/ews/Exchange.asmx";FindItemType request = new FindItemType(); request.ItemShape = new ItemResponseShapeType(); request.ItemShape.BaseShape = DefaultShapeNamesType.Default; request.Traversal = ItemQueryTraversalType.Shallow; request.ParentFolderIds = new BaseFolderIdType\[1\]; DistinguishedFolderIdType inbox = new DistinguishedFolderIdType(); inbox.Id = DistinguishedFolderIdNameType.inbox; request.ParentFolderIds\[0\] = inbox;
ServerVersionInfo objServerVersionInfo = objExchangeServiceBinding.ServerVersionInfoValue;
}But I get the following error “The request failed with HTTP status 401: Unauthorized.” Can anyone please tell me what the problem is? I will be thankful to you regards,
-
Hi, I am trying to connect with Microsoft Exchange Server using the following code
static void Main(string[] args)
{ {System.Net.ServicePointManager.ServerCertificateValidationCallback =delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
};ExchangeServiceBinding objExchangeServiceBinding = new ExchangeServiceBinding();
objExchangeServiceBinding.Credentials = new System.Net.NetworkCredential("user", "pass", "domain.com");
//objExchangeServiceBinding.AllowAutoRedirect = true;
objExchangeServiceBinding.UseDefaultCredentials = true;
objExchangeServiceBinding.Url = "https://10.11.1.250/ews/Exchange.asmx";FindItemType request = new FindItemType(); request.ItemShape = new ItemResponseShapeType(); request.ItemShape.BaseShape = DefaultShapeNamesType.Default; request.Traversal = ItemQueryTraversalType.Shallow; request.ParentFolderIds = new BaseFolderIdType\[1\]; DistinguishedFolderIdType inbox = new DistinguishedFolderIdType(); inbox.Id = DistinguishedFolderIdNameType.inbox; request.ParentFolderIds\[0\] = inbox;
ServerVersionInfo objServerVersionInfo = objExchangeServiceBinding.ServerVersionInfoValue;
}But I get the following error “The request failed with HTTP status 401: Unauthorized.” Can anyone please tell me what the problem is? I will be thankful to you regards,
-
Please check your Network credential.if possible then login to OWA from this credential for varification.
Cheers!! Brij
Thanks for your reply, I can login to OWA using the same username, password and domain, but it creates problem when I try it through code as I mentioned. :(