CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Working NT Authentication code with Access DB

Print topic Send  topic

Author Message
mramirez18

Posts: 56
Posted: 08/28/2006, 7:03 PM

Does anyone have a working NT Authentication login page, which works with Access DB..The users are in access db, aswell group_id's for privileges.

I have tried the code that Robert Massey Posted: 01/28/2004, 8:51 AM, but I have had no joy.

Can someone help.
View profile  Send private message
mramirez18

Posts: 56
Posted: 08/28/2006, 7:32 PM

This is the code I am trying to use. I have created the LOGIN page, where does the code go, is there anything else that needs to be done. Do I need to configure IIS?

<%
on error resume next

strUserName=Request.Form("username")
strPassword=Request.Form("password")
stay=Request.Form("stay")

Dim strDomain
strDomain = "OURDOMAINNAME"
Dim strADsPath
strADsPath = strDomain
'Flags 1 = Secure authentication flag 0 = unsecure
Dim iFlags
iFlags = 1

if (not strADsPath= "") then
' bind to the ADSI object. If user has supplied a username, then
' authenticate too
strADsPath = "WinNT://" & strADsPath
Dim oADsObject
Dim tempstr
tempstr = strDomain & "\" & strUserName

Set oADsObject = GetObject(strADsPath)
'response.write "Authenticating<br>"
Dim strADsNamespace
Dim oADsNamespace
strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
set oADsNamespace = GetObject(strADsNamespace)

Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr, strPassword, 0)

' we've only managed to bind if err.number = 0
if not (Err.number = 0) then
Notloggedin2 = "There was an error logging in! Check your login name and password.<br>" _
& "The login name and password is the same as your NT Account or email.<br>" _
& "Try again. <A href=login.htm>Click Here</a>"
response.write fontstuff
response.write "<center><BR>"
response.write Notloggedin2
else

'Get user full name from our HR system all users have an NT account so should be in our HR system.
Conn_Str = "dsn=HRMS;uid=ID;pwd=PWD"
' Open Connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open Conn_Str

set rs = Server.CreateObject("ADODB.Recordset")
set RS =Conn.Execute("SELECT FirstName, LastName FROM [vPERSONS_ESS] WHERE username = '" & strUserName & "'")

if not RS.eof then
RS.movefirst
Do
UserFullName = TRIM(RS("FirstName")) & " " & TRIM(RS("LastName"))
RS.movenext
Loop until RS.eof
RS.movefirst
End if

rs.Close
Set rs = Nothing
Conn.Close
Set Conn = Nothing

if stay="" then
Response.Cookies("USERNAME") = strUserName
Response.Cookies("USERFULLNAME") = UserFullName
response.redirect "index.asp"
end if

if UCASE(stay) ="ON" then
Response.Cookies("USERNAME") = strUserName
Response.Cookies("USERNAME").Expires=#May 10,2010#
Response.Cookies("USERFULLNAME") = UserFullName
Response.Cookies("USERFULLNAME").Expires=#May 10,2010#
response.redirect "index.asp"
end if
end if
end if
%>
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.