473,831 Members | 2,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP page to validate username with AD

Hello,

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:

<html>

<head>
<meta http-equiv="Content-Language" content="nl-be">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="GENERATOR " content="Micros oft FrontPage 4.0">
<meta name="ProgId" content="FrontP age.Editor.Docu ment">
<title>username </title>
</head>

<body>
<SCRIPT LANGUAGE=VBScri pt>

<!--

Option Explicit

Dim bValid
Dim oRootDSE
Dim oDSObj
Dim oAuth
Dim szNamingContext
Const ADS_SECURE_AUTH ENTICATION=1
Dim szUserId, szPasswd
Sub B1_OnClick

bValid = True

Call CheckField(docu ment.form1.user name.Value, "Please enter a
value in the field.")
Call CheckField(docu ment.form1.pass word.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("d efaultNamingCon text")
' Validate against the namespace
Set oDSObj = GetObject("LDAP :")
Set oAuth = oDSObj.OpenDSOb ject("LDAP://" & szNamingContext , _
szUserId, szPasswd, ADS_SECURE_AUTH ENTICATION)

' User authenticated if we get here
bAuthenticateUs er = True
End If

End Sub

Sub CheckField(ByVa l strFieldValue, ByVal strMessage)

If strFieldValue = "" Then

MsgBox strMessage, 0

bValid = False

End If

End Sub

-->

</Script>

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

name="B1">&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;

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

</body>

</html>

Nov 18 '05 #1
0 1366

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1824
by: Shelly | last post by:
I set a session variable on error in the login page and then call the login page again. I test on that session variable but it shows as not set. I checked with an echo immediately after setting the error session variable so I am 100% positive that it is set. The recursive entry to the login page echos a message that the error session variable is unset. Any clues? Here is the setting code and the testing code (commented out)"...
5
12113
by: Joeri KUMBRUCK | last post by:
Hello, 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: my script stops at the line: Set oRootDSE = GetObject("LDAP://RootDSE") Why is this GetObject...
5
3868
by: Joeri KUMBRUCK | last post by:
Hello, 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...
2
7600
by: Steffen Balslev | last post by:
I tried to find a way to validate user credentials using C#, searching google and lots of other news and kb sites left me without a solution. You can use a SSPI but it's that easy to implement so I found a simple way and here it is: using System.DirectoryServices; public bool Win2kCredentialsIsValid(string domain, string username, string password) { bool validLogin = false; string adPath = "LDAP://" + domain + "/rootDSE";
7
10230
by: Lubo¹ ©lapák | last post by:
Hi, I have a login page and after click on button Login I check username and password and if it is correct, i want load page, which was there before Login page. How can I do it? In javascript it is simply <script language="javascript">window.history.back();</script> but How can I do it in C# code? Please help. Thanks Lubos
6
4908
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
2
3913
by: Shakun | last post by:
Hi All, This is my 1st posting to this group. Can any1 help me with the "Remember Me" which is there in a login form. Im pasting the code below. Im not able to set a cookie.. Thanks, Shakun Vohra
5
4539
by: accessman2 | last post by:
Hi, I have a question. I made the create the new user form. <script language="javascript"> function submitFrm() {
2
1585
mideastgirl
by: mideastgirl | last post by:
Warning: session_start() : Cannot send session cookie - headers already sent by (output started at /home/content/m/i/d/mideasthonors/html/adminloginprocess.php:1) in /home/content/m/i/d/mideasthonors/html/adminloginprocess.php on line 5 Warning: session_start() : Cannot send session cache limiter - headers already sent (output started at /home/content/m/i/d/mideasthonors/html/adminloginprocess.php:1) in...
0
9793
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10777
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10494
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9317
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5620
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3964
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.