Running Web Services through the Proxies generated by WSDL through the credentials of the caller

Web Services accessed either through their Proxy Classes that are generated using the Web Services Description Language (WSDL) tool (Wsdl.exe), or through the addition of a Web reference, by default do not run under the credentials of the caller.

Web Services accessed either through their Proxy Classes that are generated using the Web Services Description Language (WSDL) tool (Wsdl.exe), or through the addition of a Web reference, by default do not run under the credentials of the caller.

The Proxies thus generated, have a property called "Credentials" which can be used to send the security credentials of the current user for the Client Authentication. It can be used by creating an instance of a class that implements the Icredentials interface (e.g. NetworkCredential class).

The below snippet shows its usage.

//Put this statement before the call
proxyName.Credentials = System.Net.CredentialCache.DefaultCredentials

Note: Anonynmous Authentication should be turned off, and Windows Authentication is turned on for this to work. For a Windows App, this will be the Windows Credentials, and for the ASP.Net Apps it will be the Credentials of the Worker Process

By [)ia6l0 iii   Popularity  (1159 Views)