views:

28

answers:

1

If WebApp is configured as Windows Authentication, how to get the user credential in code? How to create NetworkCredential using this exsiting user credential?

+1  A: 
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;
rick schott
System.Net.CredentialCache.DefaultCredential is not available for silverlight 4 even adding reference for System.Net. Maybe this assessment has different version for silverlight sandbox.
KentZhou
You should put those details in your question, you only have ASP.NET tagged.
rick schott