Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Connection problem with MS Exchange Server

Connection problem with MS Exchange Server

Scheduled Pinned Locked Moved C#
helpcsharpcomsysadmincryptography
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    free_soul424
    wrote on last edited by
    #1

    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,

    B 1 Reply Last reply
    0
    • F free_soul424

      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,

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      Please check your Network credential.if possible then login to OWA from this credential for varification.

      Cheers!! Brij

      F 1 Reply Last reply
      0
      • B Brij

        Please check your Network credential.if possible then login to OWA from this credential for varification.

        Cheers!! Brij

        F Offline
        F Offline
        free_soul424
        wrote on last edited by
        #3

        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. :(

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups