473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Ldap search within active directory for authentication via ASP

3
Hi, I hope you guys can help me.

I need to build a form that request username and password on ASP not ASP.net (sorry to clarify but i got some responses in other forums in .net)

This form will send an LDAP query into the active directory located on a different server and it will check for existing users.

If the users exist they will be redirected to a new page. if not they will be prompt to try again for username and password.


What is happening I am gett authentication failed all the time. I know i am a user but I dont know why I am not being redirected to the page i need.

could it be that the server is using another way of saving the users other than LDAP or Active directory?

To be more specific. People are being added to an Xchange server for email purposes. This creates a username (email) and a password. Giving them access to a webmail.

how can i compare this list of users using this code.

the form i am working with is this

Expand|Select|Wrap|Line Numbers
  1. <%
  2. dim submit
  3. dim UserName
  4. dim Password
  5.  
  6. UserName = ""
  7. Password = ""
  8. Domain = "domain.com"
  9.  
  10. submit = request.form("submit")
  11.  
  12. if submit = "Authenticate" then
  13. UserName = request.form("UserName")
  14. Password = request.form("Password")
  15. Domain = request.form("Domain")
  16. result = AuthenticateUser(UserName, Password, Domain)
  17. if result then
  18. Response.Write("<script>window.open('../forms/default.asp','');</script>")
  19. else
  20. response.write "<h3>Authentication Failed!</h3>"
  21. end if
  22. end if
  23.  
  24. response.write "<hr><form method=post>"
  25. response.write "<table>"
  26. response.write "<tr>"
  27. response.write "<td><b>Username:&nbsp;</b></td><td><input type='text'"
  28. name="'UserName' value='' & UserName & '' size='30'></td>"
  29. response.write "</tr>"
  30. response.write "<tr>"
  31. response.write "<td><b>Password:&nbsp;</b></td><td><input type='password' name='Password' value='' & Password & '' size='30'></td>"
  32. response.write "</tr>"
  33. response.write "<tr>"
  34. response.write "<td><b>AD Domain:&nbsp;</b></td><td><input type='text' name='Domain' value='' & Domain & '' size='30'></td>"
  35. response.write "</tr>"
  36. response.write "<tr>"
  37. response.write "<td>&nbsp;</td><td><input name='submit' type='submit' value='Authenticate'></td>"
  38. response.write "</tr>"
  39. response.write "</table>"
  40. response.write "</form>"
  41. response.end
  42.  
  43. function AuthenticateUser(UserName, Password, Domain)
  44. dim strUser
  45. ' assume failure
  46. AuthenticateUser = false
  47.  
  48. strUser = UserName
  49. strPassword = Password
  50.  
  51. strQuery = "SELECT cn FROM 'LDAP://" & Domain & "' WHERE objectClass='*' "
  52. set oConn = server.CreateObject("ADODB.Connection")
  53. oConn.Provider = "ADsDSOOBJECT"
  54. oConn.Properties("User ID") = strUser
  55. oConn.Properties("Password") = strPassword
  56. oConn.Properties("Encrypt Password") = true
  57. oConn.open "DS Query", strUser, strPassword
  58.  
  59. set cmd = server.CreateObject("ADODB.Command")
  60. set cmd.ActiveConnection = oConn
  61. cmd.CommandText = strQuery
  62. on error resume next
  63. set oRS = cmd.Execute
  64. if oRS.bof or oRS.eof then
  65. AuthenticateUser = false
  66. else
  67. AuthenticateUser = true
  68.  
  69. end if
  70. set oRS = nothing
  71. set oConn = nothing
  72.  
  73. end function
  74.  
  75. %>
Oct 2 '09 #1
5 5470
CroCrew
564 Expert 512MB
Hello wak0,

Question: Is the web server in the domain? Or is it a standalone web server?

CroCrew~
Oct 9 '09 #2
wak0
3
stand alone. Thanks for replying
Oct 9 '09 #3
CroCrew
564 Expert 512MB
Hello wak0,

Since you are doing a server-less bind to Active Directory, ADSI tries to pick up the domain to use based on the current security context of the executing thread. In ASP, impersonation is always used.

Try to add “/rootDSE” after your domain name:

LDAP://domain.com/rootDSE

In general, if the web server was within the domain, I'd suggest using Windows authentication instead. Windows Authentication allows you to avoid this mess and will give you better scalability.

Consider going down this path if Windows Authentication is absolutely not a possibility:

Expand|Select|Wrap|Line Numbers
  1. Set objDSObj = GetObject("LDAP:")
  2. Set objAuth = objDSObj.OpenDSObject("LDAP://domain.com/rootDSE",
  3. strDomainUser, strPassword, 1)
  4.  

Hope that it helps,
CroCrew~
Oct 9 '09 #4
wak0
3
that is what i found out. thanks for the tip. will implement and check back
Oct 9 '09 #5
CroCrew
564 Expert 512MB
Let us know if it works out for ya. It could help the next person.

Good luck,
CroCrew~
Oct 9 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Victor Lokhmatov | last post by:
Hello Everyone, My company has asked me to put a company directory on our intranet site and I'm trying to use php to extract the users from our active directory server. I've got everything...
5
by: dmcconkey | last post by:
Hi folks, I've been searching for a while and haven't found my specific question anywhere else. If this has already been asked, please accept my appologies and point me to the appropriate...
7
by: Amar | last post by:
I am trying to connect to my college LDAP directory using ASP.NET. This LDap does not have security as it returns only user demographic information. i do not need to bind with a username or...
3
by: mrwoopey | last post by:
Hi, I am using the example "Authenticate against the Active Directory by Using Forms Authentication and Visual Basic .NET": http://support.microsoft.com/default.aspx?scid=KB;EN-US;326340 ...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
5
by: Ganesh Ramamurthy | last post by:
Hi Experts, I am using windows Authenication in my ASP.Net application. I have different LDAP's configured in my network and my applicaiton uses one of these LDAP users. How can I specify IIS to...
1
by: Serge | last post by:
Good Day Folks, I'm trying to do an LDAP search of Novell eDirectory, but I'm getting a compile error. The error and my code are listed below. Any ideas ? Thanks in advance /Serge
2
by: P Webster | last post by:
We recently moved a web site that validated user credentials in Active Directory from IIS 5.1 to IIS 6, and the validation code no longer works. The web.config file is set to Windows authentication...
2
by: duncan beaumont | last post by:
Hi, - SQLserver 2000 - Yellowfin 2.4 - Windows 2003 server I have been asked to investigate seting up LDAP authentication to access our Yellowfin reporting.
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.