Live instructor-led online courses in ASP.NET Core and Design Patterns. Registration is open for November 2018 batch. More details are available 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 December 2002
Tags : ASP.NET Web Services Security Configuration
is a software consultant, trainer, author and spiritual yoga mentor having 23+ years of experience in software development. He teaches online training courses
in ASP.NET Core, Angular, and Design Patterns to individuals and small groups. He is a published author and has authored or co-authored books for Apress and Wrox press. Having embraced the Yoga way of life he also teaches Ajapa Yoga
to interested individuals. To know more about him click here
Get connected : Twitter Facebook