Click here to Skip to main content
15,888,286 members
Articles / Web Development / IIS
Article

Web-based Active Directory Login

Rate me:
Please Sign up or sign in to vote.
4.79/5 (18 votes)
9 Oct 20032 min read 418.7K   9.2K   59   99
Web-based Active Directory Login

Image 1

Overview

Web-based Active Directory Login implements central sign-on system for web-based applications. It was developed to eliminate maintenance of user passwords in database, whether encrypted or not. A user running application from desktop enjoys liberty to access resources and/or services on the network which he has permission to do from Windows. On the other hand, web-based applications run in a security context entirely different from that of a desktop application. Same user while running application from browser will not have such liberty. This was the problem when I tried to login using my n/w user name and password maintained in Active Directory through web. Ultimately it was overcome by impersonating the web server anonymous user which in most cases is IUSR_machinename.

Using the code

Below is a brief description of how to use the code.

There are two class files

  1. LoginAdmin
  2. prjLogin

LoginAdmin is an ActiveX DLL type project and contains a standard module and a class module. The ImpersonateUser class has two methods which you will be using in your ASP code.

VBScript
' create an object of ImpersonateUser class
 Set objLogon = Server.CreateObject("LoginAdmin.ImpersonateUser")
 
' any domain user who has rights to access active directory
 objLogon.Logon "user id", "password", "domain name"

 objLogon.Logoff
 Set objLogon = Nothing

These are the methods of the class ImpersonateUser and their description:

MethodDescription
Logon(strUser, strPassword, strDomain)This method should be called before sending request to active directory. The user should be a valid domain user with at least read permissions of active directory. You can keep this user in a database or hardcode it's userid and password in the ASP script.
LogOff()This method must be called after accessing info from Active Directory in order for IIS to revert security permissions of the particular file

prjLogin is also an ActiveX DLL type project and contains only a class module. It uses references to Active DS type library. The clsDomainLogin class has one method with three parameters user name, password and domain.

VBScript
' create an object of clsDomainLogin class
 Set oUser = Server.CreateObject("prjLogin.clsDomainLogin")

' BindObject has three parameters userid, password and domain name
 iResult = oUser.BindObject(strUser, strPassword, strDomain)

Below is a method of the class clsDomainLogin and its description:

MethodDescription
BindObject(strUser, strPassword, strDomain)This method should be called while authenticating from Active Directory. It returns 1 when successful and 0 when unsuccessful

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer The Shams Group
Pakistan Pakistan
Faisal is Senior Team Lead at The Shams Group, Karachi. He has 10+ years of experience in the field of software/ web development and infrastructure management.
He has worked on various tools and platform which includes VB, ASP, ASP.NET, Javascript, COM/COM+, SQL Server, Informix, Active Directory, UNIX/Solaris, WSH, Windows NT/ 2000 servers, RADIUS, SMTP, POP, IMAP etc.
He likes to watch movies, hangs out with friends and loves to make new friends.

Comments and Discussions

 
GeneralRe: Group Check Pin
bnk20009-Sep-04 20:39
bnk20009-Sep-04 20:39 
GeneralImpersonate for writing files to network share Pin
pbuddy11-Jun-04 7:45
pbuddy11-Jun-04 7:45 
GeneralRe: Impersonate for writing files to network share Pin
Faisal Haroon15-Jun-04 0:53
Faisal Haroon15-Jun-04 0:53 
GeneralRe: Impersonate for writing files to network share Pin
Faisal Haroon15-Jun-04 1:00
Faisal Haroon15-Jun-04 1:00 
GeneralRe: Impersonate for writing files to network share Pin
pbuddy23-Jun-04 6:35
pbuddy23-Jun-04 6:35 
GeneralSecurity context Pin
[DEN]Cap30-May-04 13:04
[DEN]Cap30-May-04 13:04 
GeneralRe: Security context Pin
Faisal Haroon30-May-04 19:45
Faisal Haroon30-May-04 19:45 
GeneralRe: Security context Pin
[DEN]Cap3-Jun-04 9:27
[DEN]Cap3-Jun-04 9:27 
GeneralProblem Pin
Anonymous27-May-04 16:09
Anonymous27-May-04 16:09 
GeneralRe: Problem Pin
Faisal Haroon27-May-04 18:39
Faisal Haroon27-May-04 18:39 
GeneralRe: Problem Pin
magn3t030-Jun-04 14:47
magn3t030-Jun-04 14:47 
GeneralThanks Pin
ejx27-May-04 4:52
ejx27-May-04 4:52 
GeneralRe: Thanks Pin
Anonymous27-May-04 16:11
Anonymous27-May-04 16:11 
GeneralRe: Thanks Pin
Faisal Haroon27-May-04 18:29
Faisal Haroon27-May-04 18:29 
GeneralSecurity problem Pin
SpaceGirl10-May-04 4:15
SpaceGirl10-May-04 4:15 
GeneralRe: Security problem Pin
Faisal Haroon10-May-04 21:06
Faisal Haroon10-May-04 21:06 
GeneralRe: Security problem Pin
SpaceGirl10-May-04 21:56
SpaceGirl10-May-04 21:56 
GeneralLogin to other folder/pages Pin
francisco22122-Feb-04 2:18
francisco22122-Feb-04 2:18 
GeneralImpersonate session object Pin
27-Jan-04 4:26
suss27-Jan-04 4:26 
GeneralRe: Impersonate session object Pin
Faisal Haroon27-Jan-04 22:00
Faisal Haroon27-Jan-04 22:00 
GeneralI need different way to show search results Pin
u999nik31-Oct-03 7:20
u999nik31-Oct-03 7:20 
GeneralRe: I need different way to show search results Pin
Faisal Haroon2-Nov-03 17:38
Faisal Haroon2-Nov-03 17:38 
GeneralQuick question regarding the context of impersonateUser Pin
Sage16-Oct-03 7:10
Sage16-Oct-03 7:10 
GeneralRe: Quick question regarding the context of impersonateUser Pin
Faisal Haroon16-Oct-03 19:24
Faisal Haroon16-Oct-03 19:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.