开发者

How to get user account info in code with Windows Authentication?

开发者 https://www.devze.com 2023-01-08 09:54 出处:网络
If WebApp is configured as Windows Au开发者_如何学运维thentication, how to get the user credential in code?

If WebApp is configured as Windows Au开发者_如何学运维thentication, how to get the user credential in code? How to create NetworkCredential using this exsiting user credential?


System.Net.CredentialCache.DefaultCredentials;

The DefaultCredentials property applies only to NTLM, negotiate, and Kerberos-based authentication.

DefaultCredentials represents the system credentials for the current security context in which the application is running. For a client-side application, these are usually the Windows credentials (user name, password, and domain) of the user running the application. For ASP.NET applications, the default credentials are the user credentials of the logged-in user, or the user being impersonated.

Example:

 System.Net.WebProxy proxyObject = new System.Net.WebProxy();
 proxyObject.Credentials = System.Net.CredentialCache.DefaultCredentials;
0

精彩评论

暂无评论...
验证码 换一张
取 消