ASP page to validate username with AD

Discussion in 'ASP .Net' started by Joeri KUMBRUCK, Aug 31, 2004.

  1. 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="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>username</title>
    </head>

    <body>
    <SCRIPT LANGUAGE=VBScript>

    <!--

    Option Explicit

    Dim bValid
    Dim oRootDSE
    Dim oDSObj
    Dim oAuth
    Dim szNamingContext
    Const ADS_SECURE_AUTHENTICATION=1
    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, _
    szUserId, szPasswd, ADS_SECURE_AUTHENTICATION)

    ' 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

    -->

    </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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input
    type="submit" value="Submit"

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

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



    </body>

    </html>
     
    Joeri KUMBRUCK, Aug 31, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joeri KUMBRUCK
    Replies:
    1
    Views:
    4,551
    Ben Lovell
    Aug 30, 2004
  2. VM
    Replies:
    1
    Views:
    647
    =?Utf-8?B?WTJLUFJBQlU=?=
    Sep 27, 2006
  3. Shailesh Patel
    Replies:
    0
    Views:
    483
    Shailesh Patel
    Nov 8, 2006
  4. Joeri KUMBRUCK

    cretae ASP page to validate username with AD

    Joeri KUMBRUCK, Aug 31, 2004, in forum: ASP General
    Replies:
    5
    Views:
    176
    Joeri Kumbruck
    Aug 31, 2004
  5. Rahul Mehta
    Replies:
    1
    Views:
    108
    Denis McMahon
    Jul 31, 2010
Loading...

Share This Page