Groups | Blog | Home
all groups > inetserver asp components > october 2003 >

inetserver asp components : ASP login


Jason
10/8/2003 8:06:03 AM
I need help developing a script to log users in to my
website. I want the users to be logged in to
Windows/Active Directory via my website using an ASP login
script. Can anyone offer any advice? Are there
components that I can pass a username and password to
Active Directory to log in a user?

Thanks for your help!

Jason
10/8/2003 9:13:42 AM
Thanks, Tom! I'm gonna try it out.


[quoted text, click to view]
Jason
10/8/2003 9:41:40 AM
Tom,
The script is authenticating everything (even bogus
username/password combinations)

any advice?

here is the result I get when I input a bogus user account
(user:ddd password: ddd) -

Authenticating...

USER AUTHENTICATED!
Currently viewing object at WinNT://VSDPC/testserver
Class is Computer

[quoted text, click to view]
Ray at <%=sLocation%
10/8/2003 11:47:41 AM
Easiest thing to do is turn off anonymous access to your site.

Ray at work

[quoted text, click to view]

Tom Kaminski [MVP]
10/8/2003 11:52:19 AM
[quoted text, click to view]

<html>
<head>
</head>
<body>
<form action=authad.asp method=post>
Username: <input type=text name=strUserName><br>
Password: <input type=password name=strPassword><br>
<input type=submit name=btnSubmit>
</form>
<%
If Request.Form("strUsername") <> "" Then
Dim strADsPath
strADsPath = "WinNT://yourdomain"

'userid =
strUserName = "yourdomain\" & Request.Form("strUserName")
strPassword = Request.Form("strPassword")

if (not strADsPath= "") then 'if and ADS Object path has been provided
proceed with authentication

' bind to the ADSI object and authenticate Username and password
Dim oADsObject
Set oADsObject = GetObject(strADsPath)
response.write "Authenticating...<br><br>"
Dim strADsNamespace
Dim oADsNamespace
strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
set oADsNamespace = GetObject(strADsNamespace)
Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, strUserName,
strPassword, 0)
' we're only bound if err.number = 0
if not (Err.number = 0) then
Response.Write "<font color='red'><font size = 5><u><b>Authentication has
failed...<b></u></font></font>"
'Response.Write "Failed to bind to object <b>" & strADsPath & "</b><br>"
'response.write err.description & "<p>"
'Response.write "Error number is " & err.number & "<br>"
Session("Auth") = "NO"
else
Response.Write "<font color='blue'>USER AUTHENTICATED!</font><br>"
'Response.Write "Currently viewing object at <b>" & oADsObject.ADsPath &
"</b><br>"
'Response.Write "Class is " & oADsObject.Class & "<br>"
Session("Auth") = "YES"
end if
'response.write "<p>"
end if
End If
%>
</body>
<html>


--
Tom Kaminski IIS MVP
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://mvp.support.microsoft.com/
http://www.microsoft.com/windowsserver2003/community/centers/iis/


Tom Kaminski [MVP]
10/8/2003 1:23:32 PM
I'm not sure what to tell you, it works fine for me. Did you substitute in
your correct domain name?
You also need to throw in "on error resume next" as the first line of ASP
code.

--
Tom Kaminski IIS MVP
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://mvp.support.microsoft.com/
http://www.microsoft.com/windowsserver2003/community/centers/iis/

[quoted text, click to view]

AddThis Social Bookmark Button