Get user SMTP login through EWS?

I have a client application written using the EWS Managed API 1.1. Here's the situation:

  • The client does not start on a computer in the same domain as Exchange Server.
  • I have a username and password, but not an email address.
  • There is no commonality between a username (for example, ABC123 \ 001234) and an email address (for example, joe.bloggs@company.com ).

I can connect to EWS just fine, send messages, etc.

However, my software must detect the authenticated user email address, and for various reasons, the requirements cannot simply ask the user to provide it.

I suggested that I could get such a simple part from a web service, but I'm at a dead end!

Is this possible for 2007 and 2010?

Thanks!

+6
source share
1 answer

You may be able to do this using ExchangeService.ResolveName . I tried this with the following EWS Managed API code example on Exchange 2007 and worked like a charm:

 var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Url = new Uri("https://serv/EWS/exchange.asmx"); service.Credentials = new NetworkCredential("001234", "PasswordForUser001234", "Domain"); ServicePointManager.ServerCertificateValidationCallback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => { return true; }; var resolvedNames = service.ResolveName("001234"); foreach (var resolvedName in resolvedNames) { Console.WriteLine(resolvedName.Mailbox.Address); } 
+3
source

Source: https://habr.com/ru/post/888699/


All Articles