473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Connecting to LDAP authenticate and redirect

Hi everyone

i have pull bits of code from everywhere and built this below.
all works perfect but i would like to have a login page where i put the username and pass and the redirect to another page passing a session number wher i will be able to filter by session.
can you please help.

thank you so much in advance.

Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  2. -----------------------------filter user---------------------------
  3. <%
  4. fsCompletted = Request.QueryString("f")
  5.  
  6. If fsCompletted = 1 Then
  7.    ResultHTML = ProcessForm
  8. else
  9.    ResultHTML = "<br>"
  10. End If
  11.  
  12. Function ProcessForm
  13.    on error resume next
  14.    oUsername=Request.Form("username")
  15.    oPassword=Request.Form("password")
  16.    strUserName = Right(oUsername, Len(oUsername) - InStrRev(oUsername, "\"))
  17.    if InStr(strUserName, "@")>0 then
  18.       strUserName = Left(strUserName, InStr(strUserName, "@")-1)
  19.    end if
  20.    Set objDomain = GetObject("GC://rootDSE")
  21.    objADsPath = objDomain.Get("defaultNamingContext")
  22.    Set objDomain = Nothing
  23.    Set con = Server.CreateObject("ADODB.Connection")
  24.    con.provider ="ADsDSOObject"
  25.    con.Properties("User ID") = oUsername
  26.    con.Properties("Password") = oPassword
  27.    con.Properties("Encrypt Password") = False
  28.    con.open "Active Directory Provider"
  29.    Set Com = CreateObject("ADODB.Command")
  30.    Set Com.ActiveConnection = con
  31.    Com.CommandText ="select name,telephonenumber,mail FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
  32.    Set rs = Com.Execute
  33.    VarInfo="<p>"+rs("name")+"<br>"+rs("telephonenumber")+"<br >"+rs("mail")+"</p>"
  34.    if err.number=0 then
  35.       HTML = "<p>"+rs("name")+"<br>"+rs("telephonenumber")+"<br >"+rs("mail")+"</p>"
  36.    else
  37.       HTML = "<p>Not Authenticated</p>"
  38.    end if
  39.    Session("mail") = Rs("mail")
  40.    rs.Close
  41.    con.Close
  42.    Set rs = Nothing
  43.    Set con = Nothing
  44.    ProcessForm=HTML
  45.    'ADUSER = rs("mail")
  46.    Session("userid") = VarInfo
  47. End Function
  48. PostURL = Request.ServerVariables("SCRIPT_NAME") & "?f=1" %> 
  49. <HTML>
  50.  <HEAD>
  51.  </HEAD>
  52. <BODY>
  53. <%=ResultHTML%>
  54. <%if request.querystring("f")="" then %>
  55.      <form method="post" Action="<%=PostURL%>">
  56.       <p>Username : <input type="text" Name="username" value="" Size="25">(yourDomain/username)</p>
  57.       <p>Password : <input type="password" Name="password" Size="25"></p>
  58.       <input Name=SubmitButton Value="Authenticate User" Type=submit>
  59.      </form>
  60. <%end if%>
  61.  
  62. --<%Response.Write Session("mail")%>
  63. </BODY>
  64. </HTML>
  65.  
Apr 17 '16 #1
0 3712

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Bonegavel | last post by:
Going to sound strange, but here i go. We use Windows 2000 AD for everything. However, we are also running XAMPP (basically Apache, MySQL, PHP for windows) on a Windows box for our Intranet. I...
0
by: Colin Steadman | last post by:
I'm using the function copied below to authenticate users in LDAP before allowing them onto our intranet site. This works great! But what I'd like to do now is use the LDAP connection it creates to...
0
by: Renato Neves | last post by:
The following code is working fine, i can create the user in the Active Directory and "enable" it. My problem is that, when i'm trying to authenticate him, i can't get to work!! The user and pass...
0
by: DanC | last post by:
How connecting a ActiveX-Object on server with authentication. Situation. ASP-aplication calling a JScript-script. It has to do with permissions because the script run correct on the server. So...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
4
by: Guadala Harry | last post by:
I have a bunch of pages that host controls that work only on uplevel browsers. While most of my users have IE6, I'd like to know how to detect the browser they are actually connecting with and...
0
by: andyt_2000_uk | last post by:
Hi guys, I can currently connect, bind and authenticate a user against ActiveDirectory using OpenLdap and apache. I have apache compiled with SSL as well. I force PHP to use https:// and i get...
2
by: P Webster | last post by:
We recently moved a web site that validated user credentials in Active Directory from IIS 5.1 to IIS 6, and the validation code no longer works. The web.config file is set to Windows authentication...
3
by: eleland | last post by:
I am trying to bind to an LDAP server using php without success. I have a linux server running php compiled with open ldap. I am using the following code taken right from php.net: echo "<h3>LDAP...
3
by: Genius79 | last post by:
Hi I'm trying to do an ASP authentication using Ldap and would like to have the users directed to pages based on the Organizational Unit. My ASP knowledge is pretty basic but would really like to get...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.