Wednesday, January 19, 2011

REST: CRUD authentication in C#

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."

DefaultCredential in C#

context.Credentials = CredentialCache.DefaultCredentials;
projectsBindingSource.DataSource = context.Projects;
If you don't want to use current window credentials, you can using the following code:

ICredentials cache = new NetworkCredential("username", "password", "domain");
context.Credentials = cache;

No comments:

Post a Comment