Classic ASP Authenticate Against Active Directory -


i have classic asp website (sorry!). parts of need nt authentication enabled.

i ideally present user nice login form (rather browser prompt) authenticate against ad , usual "log in if success, show error if failure"

is possible? i've tried following on local computer not sure how test success or if expands searching against ad

<html> <head> </head> <body>     <form action="test.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") <> ""         dim stradspath         stradspath = "winnt://aria"         strusername = request.form("strusername")         strpassword = request.form("strpassword")          'set adobject = getobject("winnt:")         'set userobject = adobject.opendsobject("winnt://" & domainname, username, password, ads_secure_authentication)           if (not stradspath= "")             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)              if not (err.number = 0)                 response.write "<font color='red'><font size = 5><u><b>authentication has failed...<b></u></font></font>"                 session("auth") = "no"             else                 response.write "<font color='blue'>user authenticated!</font><br>"                 session("auth") = "yes"             end if         end if     end if     %> </body> </html> 

so once authenticated, possible grab other stuff such email , groups?

i've tried following classic asp (vbscript), 2008 r2, error using ad authenticate , tried authenticating against local machine authenticates no matter put in. fact i'm using local machine mean won't work?

i know old question, in case still interested:

this how authenticate users against ad: it's indirect approach using authenticated ldap query. if query fails, user not allowed authenticate against domain controller.

it's bit inelegant in as requires explicit naming of domain controller. domain name (if want use sam account names) , ou search start dn.

  dim domaincontroller : domaincontroller = "yourdc.company.com"   dim ldapport : ldapport = 389   dim startou : startou = "dc=company,dc=com"    function checklogin( szusername, szpassword)     checklogin = false      szusername = trim( "" &  szusername)      dim ocon : set ocon = server.createobject("adodb.connection")     ocon.provider = "adsdsoobject"     ocon.properties("user id") = szusername     ocon.properties("password") = szpassword     ocon.open "adprovider"     dim ocmd : set ocmd = server.createobject("adodb.command")     set ocmd.activeconnection = ocon      ' let's mail address of non exitsting user     dim szdummyquery : szdummyquery = "(&(objectcategory=person)(samaccountname=degaullesc))"     dim szdummyproperties : szdummyproperties = "mail"     dim cmd : cmd = "<" & "ldap://" & domaincontroller & ":" & ldapport & _                         "/" & startou & ">;" & szdummyquery & ";" & szdummyproperties & ";subtree"     ocmd.commandtext = cmd     ocmd.properties("page size") = 100     on error resume next     dim rs : set rs = ocmd.execute     if err.number = 0       checklogin = true       call rs.close()       set rs = nothing     end if     on error goto 0     set ocmd = nothing   end function    ' perform test   dim res : res = checklogin( "youradname\youruser", "yourpassword")   if res     response.write( "login ok")   else     response.write( "login failed")   end if 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -