Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Setting credentials for Exchange Service in Outlook Add-ins

$
0
0

I have method to convert the Entry Id to EWS it.

For calling the exchange service , i need to set the credentials.

If i use the UseDefaultCredentials method on ExchangeService, it will be using the windows logged in user credentials.

But i want to use the credentials that has been given in outlook since , we have a case where windows logged in credentials may not be the same as Outlook user. How to acheive this? is there a way to bind the service with outlook logged in credentials instead of windows login credentials. Code snippet given below.

 public string ConvertHexEntryIdToEwsId(string sID, string strSMTPAdd)
       {
           ExchangeVersion exchVersion = ExchangeVersion.Exchange2010;
           ExchangeService service = new ExchangeService(exchVersion);
           service.UseDefaultCredentials = true;    
           service.Url = new Uri(string.Format("https://{0}/EWS/Exchange.asmx",ConfigurationManager.AppSettings["ExchangeIP"]));
           string uniqueId = string.Empty;
           try
           {
               AlternateId objAltID = new AlternateId();
               objAltID.Format = IdFormat.HexEntryId;
               objAltID.Mailbox = strSMTPAdd;
               objAltID.UniqueId = sID;

               AlternateIdBase objAltIDBase = service.ConvertId(objAltID, IdFormat.EwsId);
               AlternateId objAltIDResp = (AlternateId)objAltIDBase;
               uniqueId = objAltIDResp.UniqueId;
           }
           catch
           {
               throw;
           }
                   return uniqueId;
       }


Partha


Partha


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>