I have a WebAPI application with Windows Authentication. I need to create connection with external application (MS Dynamics CRM 2016) inside WebAPI controller, but I cannot obtain password of connected to WebAPI user.
Is there any possibility to obtain NetworkCredentials
or ClientCredentials
object in WebAPI controller? I can get username and domain of connected user, but not password. CredentialCache.DefaultNetworkCredentials
object is empty.
public class ParametersController : ApiController
{
public IHttpActionResult GetParameters()
{
NetworkCredential defaultNetworkCredentials = CredentialCache.DefaultNetworkCredentials; //null
return this.Ok();
}
}
You can not get the password from windows authentication for the same reason that you cannot make a public website with windows authentication where you can get all the password of the visitors account without them knowing. This is a security feature.