Windows Authentication In A Web Application

From PresenceWiki
Revision as of 11:13, 23 August 2010 by Graham (Talk | contribs)

Jump to: navigation, search
Tutorial Pages > Windows Authentication In A Web Application

This document describes the processes needed to Autenticate a user accessing your pages by using their windows username and password.

This will then also enable you to track users through the site, so for instance, if they press a button on the site to action an event, you'll be able to log who actioned the event.

The advantages of this are that:-

The user can use their windows username and password.
The httpsession variable is used so that the user only needs to login once.
The username is stored against the ip address, so that it will only need to be entered once for a machine.
A session will automatically expire when no new requests have been made for a set time.

You can download the tasks for this example from:-

Once imported they should look like:-

Simple Task To Confirm Action is the exampkle task that shows you how to use Check Login Sub Task in your ondemand tasks.

Instructions task explains how to configure the tasks.

Session Expiry is a queued task that querys the Demo.UserLogin table effectively expiring unused sessions.

Check Login Sub Task calls Login and updates the users details in the Demo.USerLogin table.

Login querys the username and password against the system and either returns a null response or a login panel.

Check User Exists in LDAP performs an LDAP Query against your active directory to Query if the username exists.

To embed the task, we just place the "Check Login Sub Task" before our normal ondemand task page. It might be that all ondemand pages start from one single task, in which case we would place the "Check Login Sub Task" at the start of that task.

Start the httpserver and go to http://localhost/task/newconfirmtask

The first time you should see the following:-

This will require a valid windows username and password combination:-

If the password is incorrect then you will get the following:-

The username is looked up via an LDAP Query, so if it does not exist you will see:-

If the username and password are valid, then the "" task will return null, and so the calling task will continue in this case showing the task select ondemand screen.

AS the task validates that the http session is logged in, Once the user is logged in they will stay logged in.

If they don't undertake an action for 20 minutes, the session is reset and they are effectively logged out.