473,668 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP page to authenticate username and password with active directory

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 thing giving so much problems and is there a
way to let it work? Maybe there are already scripts available to do
the same thing, anyway, all help is welcome. Here comes 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
1 4264
Could you just check for membership to a particular role in your AD domain?
If so, this would be much simpler to achieve using the
IPrincipal.IsIn Role(...) method.

--
Ben
http://bitarray.co.uk/ben
"Joeri KUMBRUCK" <Jo************ @dhl.com> wrote in message
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:
my script stops at the line:
Set oRootDSE = GetObject("LDAP ://RootDSE")
Why is this GetObject thing giving so much problems and is there a
way to let it work? Maybe there are already scripts available to do
the same thing, anyway, all help is welcome. Here comes 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 #2

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

Similar topics

5
12102
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
5801
by: Bud | last post by:
I would like to be able to pass a request to IIS to have a user name and password authenticated against my Active Directory Users database. I'm running Server 2003 however my web pages are build using ASP (not .NET). What I want to do is to open the standard User Name/Password form (I don't know how to do that either) and then make my request and get back a True/False result. There must be a way to do that but I haven't found it after 3...
1
7306
by: anonymous | last post by:
Hi all, I've been searching the way to achieve the following task. But no luck so far. I have a web site(main site), which requires authentication. This authentication is set at Windows directory level, so user will see the pop up gray box in order to log in rather than custom web page. The username and password are stored at active directory level, thus this is the windows integrated security.
7
5212
by: Sync Walantaji | last post by:
Hi, I would like to write a asp.net winform program to authenticate users on Active Directory. Can I do this with asp.net if the IIS server is not part of the Active directory domain? Is there a working example link that you can point me to? Thanks
1
2944
by: Christopher | last post by:
We are using forms authentication in our web app and typically query our LDAP Servers by binding to the user node in the LDAP Tree. We usually see the following DN used as the DN for each user.. http://serverip:389/cn=login,dc=company,dc=org *where login is their actual windows login In Active Directory we are seeing this format... http://server:389/cn=firstname lastname,dc=company,dc=org
1
4555
by: kevin.vaughan | last post by:
Hello Everyone, Is it possible to authenticate the windows password through Active Directory? If so, how would this be done. I have a login screen in my application and am trying to set it up with the same login details as Windows to streamline the experience for users. It also must allow 1 user to log onto the application while another user is logged onto windows. I must know who is logged onto the
3
26643
by: dorrit.Riemenschneider | last post by:
I need to validate a user with username and password against our OpenLDAP active directory. This is my code: Private bool ValidateUser (string username, string password) { DirectoryEntry userEntry = new DirectoryEntry( ldapPath, username, password, AuthenticationTypes.Anonymous); //Bind to the native AdsObject to force authentication.
1
13232
by: fomalhaut | last post by:
Hi All, I'm builing an application that requires domain admin access to run, and I'm trying to allow for the application to be run as a normal user and allow the user to provide it with a username/password that has the access. I have a method that will check if the username/password is correct, however, it will only authenticate the user running the program...
1
3504
by: Michael Howes | last post by:
I would think this would be very, very easy but in the 50 searches I've done I haven't found anything. If our application requires login and that user/password be a local windows account or more detailed, a user that has been added to the Power Users group that is either a local account or a active directory account how do I authenticate? I've found code that seems to do this against Active Directory
2
4479
by: =?ISO-8859-1?Q?Bj=F6rn_K?= | last post by:
Hello Guys, i need to program an ASP.net Webapplication. This application should be only used by members of a specific group. So I want to write a Login-page like this: Username: Password: (Login-Button)
0
8462
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
8381
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
8893
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
8797
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
8656
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
4205
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
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.