473,663 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ldap search within active directory for authentication via ASP

3 New Member
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 5487
CroCrew
564 Recognized Expert Contributor
Hello wak0,

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

CroCrew~
Oct 9 '09 #2
wak0
3 New Member
stand alone. Thanks for replying
Oct 9 '09 #3
CroCrew
564 Recognized Expert Contributor
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 New Member
that is what i found out. thanks for the tip. will implement and check back
Oct 9 '09 #5
CroCrew
564 Recognized Expert Contributor
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
5521
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 working, however, when the list of users is shown in the output, it seems to display the users in the order their accounts were created, with Administrator obviously being first. What do you think would be the best way to get the list to be sorted by...
5
2867
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 thread. I'm bidding on a PHP intranet development contract. One of the specific requirements is that the app interface with the company's existing Open LDAP server for user authentication.
7
6798
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 credentials. What i am trying to do is, i am trying to look up all the information for the user with user id 'testuser'. The following is the Vb.net code for my aspx page: Dim oRoot As DirectoryEntry = New...
3
16434
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 But I am having a problem figuring out the LDAP:// The LDAP:// that I pass looks like this (i substitued generic the
1
4747
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 I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I have a page in a folder (under anonymous authentication in IIS6) that has a link on it that...
5
1523
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 use one of these LDAP for user authentication. Is there any way of instructing the IIS to do so? Thanking in advance Regards
1
368
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
4689
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 because all we do is verify the user on the login form so we can redirect them to the appropriate page based on their group. The code to authenticate is: Public Function IsAuthenticated(ByVal domain As String, ByVal username As String, ByVal...
2
3250
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
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8634
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.