Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 25th, 2016, 10:01 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecting to AD

Hello ladies and gentlemen

I have "gathered" code from different sources and managed to be able to connect to my AD.

what i need and i am asking on my knees, is that i get redirected to a welcome page.

Also if i have a logout link on the welcome.asp page how can i logout from the AD (Active directory)

Below is the code

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
-----------------------------filter user---------------------------
<%
fsCompletted = Request.QueryString("f")

If fsCompletted = 1 Then
ResultHTML = ProcessForm
else
ResultHTML = "<br>"
End If

Function ProcessForm
on error resume next
oUsername=Request.Form("username")
oPassword=Request.Form("password")
strUserName = Right(oUsername, Len(oUsername) - InStrRev(oUsername, "\"))
if InStr(strUserName, "@")>0 then
strUserName = Left(strUserName, InStr(strUserName, "@")-1)
end if
Set objDomain = GetObject("GC://rootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing
Set con = Server.CreateObject("ADODB.Connection")
con.provider ="ADsDSOObject"
con.Properties("User ID") = oUsername
con.Properties("Password") = oPassword
con.Properties("Encrypt Password") = False
con.open "Active Directory Provider"
Set Com = CreateObject("ADODB.Command")
Set Com.ActiveConnection = con
Com.CommandText ="select name,telephonenumber,mail FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
Set rs = Com.Execute
VarInfo="<p>"+rs("name")+"<br>"+rs("telephonenumbe r")+"<br >"+rs("mail")+"</p>"
if err.number=0 then
HTML = "<p>"+rs("name")+"<br>"+rs("telephonenumber")+ "<br >"+rs("mail")+"</p>"
else
HTML = "<p>Not Authenticated</p>"
end if
Session("mail") = Rs("mail")
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
ProcessForm=HTML
Response.Redirect "x4_page.asp"

'ADUSER = rs("mail")
Session("userid") = VarInfo
End Function
PostURL = Request.ServerVariables("SCRIPT_NAME") & "?f=1" %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%=ResultHTML%>
<%if request.querystring("f")="" then %>
<form method="post" Action="<%=PostURL%>">
<p>Username : <input type="text" Name="username" value="" Size="25">(yourDomain/username)</p>
<p>Password : <input type="password" Name="password" Size="25"></p>
<input Name=SubmitButton Value="Authenticate User" Type=submit>
</form>
<%end if%>

--<%Response.Write Session("mail")%>
</BODY>
</HTML>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching AD everest C# 2005 11 October 9th, 2007 04:39 PM
Add existing AD user to AD group via ADSI? thiazi Classic ASP Basics 0 August 24th, 2007 09:27 PM
Ad Rotator js_newbie Javascript 0 April 4th, 2007 11:30 PM
Ad ImpressionCount? developerz BOOK: ASP.NET Website Programming Problem-Design-Solution 0 November 17th, 2003 11:34 AM



All times are GMT -4. The time now is 03:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.