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> </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> </p>
<p align="center">
&nb sp; &nb sp; <input
type="submit" value="Submit"
name="B1">  ; &n bsp;   ; &n bsp;   ;
<input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html> 5 3868
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> </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> </p> <p align="center"> &nb sp; &nb sp; <input type="submit" value="Submit"
name="B1">  ; &n bsp;   ; &n bsp;   ; <input type="reset" value="Reset" name="B2"></p> </form> </body>
</html>
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!
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"
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> </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> </p> <p align="center"> &nb sp; &nb sp; <input type="submit" value="Submit"
name="B1">  ; &n bsp;   ; &n bsp;   ; <input type="reset" value="Reset" name="B2"></p> </form> </body>
</html>
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! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 way to get the info into
the Post environment variable and add code for the PHP page to read it...
|
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)"...
|
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...
|
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";
|
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
| |
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...
|
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...
|
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
|
by: accessman2 |
last post by:
Hi,
I have a question.
I made the create the new user form.
<script language="javascript">
function submitFrm()
{
|
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...
|
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,...
| |
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...
|
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...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |