By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,836 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,836 IT Pros & Developers. It's quick & easy.

ASP page to validate username with AD

P: n/a

I'm trying to create an ASP page where users can type in a username
and password, and these credential should be checked with active
directory. If username and password are correct, the script will
continue to run otherwise it will stop. Below you will find my code
I've programmed until now, at this moment I've got one big problem:
the vbs part of the script works fine if you run it as a vbs file. If
I copy/paste it into an ASP page, it doesn't work anymore. Anyone
ideas how I can solve this?
Here is the code:


<meta http-equiv="Content-Language" content="nl-be">
<meta http-equiv="Content-Type" content="text/html;
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">



Option Explicit

Dim bValid
Dim oRootDSE
Dim oDSObj
Dim oAuth
Dim szNamingContext
Dim szUserId, szPasswd
Sub B1_OnClick

bValid = True

Call CheckField(document.form1.username.Value, "Please enter a
value in the field.")
Call CheckField(document.form1.password.Value, "Please enter a
value in the field.")
If bValid Then

szUserId = document.form1.username.value
szPasswd = document.form1.password.value
' Retrieve the current domain
Set oRootDSE = GetObject("LDAP://RootDSE")

szNamingContext = oRootDSE.Get("defaultNamingContext")
' Validate against the namespace
Set oDSObj = GetObject("LDAP:")
Set oAuth = oDSObj.OpenDSObject("LDAP://" & szNamingContext, _

' User authenticated if we get here
bAuthenticateUser = True
End If

End Sub

Sub CheckField(ByVal strFieldValue, ByVal strMessage)

If strFieldValue = "" Then

MsgBox strMessage, 0

bValid = False

End If

End Sub



<FORM NAME="form1">
<p align="center">username: <input type="text" name="username"
<p align="center">password: <input type="password" name="password"
<p align="center">&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; <input
type="submit" value="Submit"

name="B1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="Reset" name="B2"></p>



Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.