CredentialCache.DefaultNetworkCredentials not returning currently logged in user. ExchangeService

759 Views Asked by At

I'm trying to pass the currently logged on user's credentials to the Exchange Web Services Managed API. Not trying to inspect them or check the values, just simply use them to make the call. The application is using windows authentication and the current windows identity is as expected.

WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent(); //returns DOMAIN\useraccount

However, CredentialCache.DefaultNetworkCredentials is returning the credentials of the application pool.

exchangeservice.Credentials = CredentialCache.DefaultNetworkCredentials;
\\Passes the application pool credentials.

I've attempted to impersonate, though I'm not sure I'm doing it correctly.

using (WindowsImpersonationContext context = identity.Impersonate())
{
    exchangeservice.Credentials = CredentialCache.DefaultNetworkCredentials; 
    \\Passes the application pool credentials.
}

The web.config sets <authentication mode="Windows" /> and IIS sets windows authentication as well. Load User Profile is set to false on the application pool.

enter image description here

Any help would be greatly appreciated.

0

There are 0 best solutions below