Learn ASP.NET MVC / Core, jQuery, Angular, and Design Patterns through our online training programs. Courses conducted by Bipin Joshi on weekends. Read more details here.
Windows Authentication with Web Services
In the previous article in this series we saw how to use SOAP headers to authenticate a web service. In this article I will show you how you can use windows credentials to authenticate the consumer of your web service. Windows authentication is commonly used in intranet scenarios such as corporate portals.
How it works?
You can enable windows authentication for your web applications using web.config file. You need to set authentication mode to Windows in the <authentication> section. Additionally you need to set <authorization> section to deny anonymous access. Once you set these parameters in the web.config file the windows credentials of client machine (i.e. the machine which is accessing the web service) will be automatically passed to the web service. In side the web service you can then use Context.User.Identity.Name to get the user name of the user. In case client is not logged in to the domain, IE will pop up a dialog box to enter user id and password. Once user enters valid credentials he will be allowed to consume the web service.
The sample source code provided contains two VS.NET projects. One is web service project that authenticates the user. The other is web application that consumes the web service.
Posted On : 07 Dec 2002
is a software consultant, trainer, author and a yogi having 21+ years
of experience in software development. He conducts online courses
in ASP.NET MVC / Core, jQuery, AngularJS, and Design Patterns
. He is a published author and has authored or co-authored books for Apress and Wrox press. Having embraced Yoga way of life he also teaches Ajapa Meditation
to interested individuals. To know more about him click here
Get connected : Twitter Facebook
This page is protected by Copyright laws.
Copying in any form is strictly prohibited.
If you find this page useful please share it using the following buttons.
Tags : ASP.NET Web Services Security Configuration