473,568 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cretae 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>

Jul 19 '05 #1
5 3855
And the error is ?

In most cases, failure running something in an ASP page when it works in a
script launched directly is relative to security.

Patrice

--

"Joeri KUMBRUCK" <Jo************ @dhl.com> a écrit dans le message de
news:41******** *******@dhl.com ...
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>

Jul 19 '05 #2
Hi Patrice,

thanks for your reply. The only error message I get, is a small warning
sign in the status bar of my IE when I launch the ASP page. The warning
sign is there for 2 seconds and I guess it's related to the first
Getobject line in my code. As I put a MasgBox before the Getobject line
and behind the Getobject line, I get only the first messagebox and not
the second, I guess it stops executing the code as soon as an error is
detected? Again, all works fine in a vbs file, but I really want to get
this working in an ASP page as I want to publish it in IIS.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3
1. You are having a vbscript problem: there was absolutely no need to show
us all that html stuff. It's up to you to make our task easier by extracting
the part of your code that causes the problem and only showing us that.
2. Please do not start a new thread for the same problem. I am sure that Tom
will respond to you in your original thread. Starting a new thread makes it
very difficult to carry on a conversation, making it harder to get a
resolution for your problem.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4
I just noticed that this script is executed client side. It's very likely
disabled for securirty reasons. You should be able to enable scritping error
report so that you have more detailed information about the error (likely
the object is nothing it creation being discarded as a result of the
security settings).

Or don't you want rather to perform this check server side ????

Patrice

--

"Patrice" <no****@nowhere .com> a écrit dans le message de
news:ul******** ******@tk2msftn gp13.phx.gbl...
And the error is ?

In most cases, failure running something in an ASP page when it works in a
script launched directly is relative to security.

Patrice

--

"Joeri KUMBRUCK" <Jo************ @dhl.com> a écrit dans le message de
news:41******** *******@dhl.com ...
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>


Jul 19 '05 #5
Patrice,
it doesn't help if I run this script from server-side. I enabled
debugging in my IE and get following error: ActiveXcomponen t can't
create object: "GetObject"
It seems that I can't use getobject in a vbscript embedded in an ASP
page???
Any suggestions?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #6

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

Similar topics

9
2695
by: william c | last post by:
I don't really know PHP that well. I'm fixing a Perl program that accesses a db after getting form input from a PHP page. If the server-side validation fails I'd like to reload the form with all the user's info still filled in. I could embed the entire page in the Perl program but it seems like there must be a better way to go. Is there a...
11
1804
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...
5
12099
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:...
2
7571
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...
7
10217
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
0
1360
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:...
6
4854
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...
2
2871
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
4530
by: accessman2 | last post by:
Hi, I have a question. I made the create the new user form. <script language="javascript"> function submitFrm() {
0
7909
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. ...
0
8115
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...
1
7654
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7961
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...
0
6273
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...
1
5492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5216
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3630
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1206
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.