Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For our particular situation, because both the client and the web service are running on our company Intranet, a solution that may work for us is to handle the Authentication on the client end using the Integrated Windows NTLM authentication, and then then just have the client supply the credentials to the Web Service. Here is the client code:</p> <pre><code>public void AddRole(string roleName) { webSvc.Credentials = CredentialCache.DefaultCredentials; // Invoke the WebMethod webSvc.AddRole(roleName); } </code></pre> <p>The web method will now look like this:</p> <pre><code>[WebMethod] public ResultObj AddRole(string roleToAdd) { IIdentity identity = Thread.CurrentPrincipal.Identity; if (!identity.IsAuthenticated) { throw new UnauthorizedAccessException( ConfigurationManager.AppSettings["NotAuthorizedErrorMsg"]); } // Remaining code to add role.... } </code></pre> <p>Again, I must stress this solution will probably only work if the server trusts the client, and both talk to the same Active Directory server. For public Web Services, one of the other answers given is going to be a better solution.</p> <p>For further information, see:</p> <ul> <li><a href="http://support.microsoft.com/kb/813834" rel="nofollow noreferrer">Microsoft Support Article on passing credentials</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/aa302383.aspx" rel="nofollow noreferrer">MSDN Article on Building Secure Applications</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/aa480475.aspx" rel="nofollow noreferrer">MSDN Article on Windows Authentication</a> - includes info on correctly configuring the web service to use the Windows Principal and Identity objects needed.</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload