Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Migrating from classic asp authentication to .net

$
0
0

I'm currently developing a new site to migrate from classic asp that runs an authentication script and sets lots of custom session variables it pulls from a SQL table depending on who the user is in iis, the script seems to have a windows login but in the classic script it also connects to LDAP directly and pulls AD variables like email address, first name, last name etc from the AD. I can emulate this in .Net on my local computer easily but when I deploy this on the remote server, the call to LDAP doesn't work and it cannot authenticate. I have (maybe mistakenly) written the .net app to use "Forms" authentication, and I have a Login.asp page that emulates the windows authentication from the toolbox, this all works fine locally on my pre-authenticated local instance. My question: do I change it to "Windows" authentication, but then how do I direct my .Net app to run the Login code behind script and still authenticate with IIS?

Maybe some code would help, here is how the classic accesses the LDAP:

Dim objConnection, objCommand, strQuery, objRecordSet, strDN, strFirst, strLast
' Use ADO to search the domain for all users.
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOOBject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

'Get userID and email string
strQuery = "<LDAP://web.com>;(&(objectClass=top)(mailNickname=" & Myname & "));mail,givenName,sn,department,company,physicalDeliveryOfficeName,pwdLastSet;subtree"

objCommand.CommandText = strQuery
objCommand.Properties("Cache Results") = False

Set objRecordSet = objCommand.Execute()
Do Until objRecordSet.EOF
  strDN = objRecordSet.Fields("mail")
  strFirst = objRecordSet.Fields("givenName")
  strLast = objRecordSet.Fields("sn")
  strOpco = objRecordSet.Fields("company")
  strDept = objRecordSet.Fields("department")
  strLastSet = objRecordSet.Fields("pwdLastSet")

  objRecordSet.MoveNext
Loop

This same code when ran on the remote server gives off a "Table does not exist" error.

I need to be able to do the same thing in asp.net.....help...


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>