?
Solved

ASP LDAP Authentication

Posted on 2004-11-08
3
Medium Priority
?
599 Views
Last Modified: 2008-03-17
I've got this code to authenticate against our Novell LDAP server for ASP.NET:

Imports System.DirectoryServices
Public Function IsAuthenticated(ByVal szUser As String, ByVal szPassword As String) As Boolean
Try
 If szUser = "" Then szUser = "none"
 If szPassword = "" Then szPassword = "none"
 Dim strServerDNS As String = "LINLDP2"
 Dim strUserDN As String = "cn=" & szUser & ", ou=people, o=ha"
 Dim strLDAPPath As String = "LDAP://" & strServerDNS & "/" & strUserDN
 Dim objDirEntry As New System.DirectoryServices.DirectoryEntry(strLDAPPath)  
 Dim szTemp As String
 With objDirEntry
   .Username = strUserDN
   .Password = szPassword
   .AuthenticationType = DirectoryServices.AuthenticationTypes.ServerBind
 End With
 Try
  szTemp = objDirEntry.Properties("cn").Value
  Catch ex As Exception
  Return False
 End Try
 Return True
 Catch ex As Exception
 Return False
End Try

End Function


I was wondering if a solution this easy exists in ASP? Please provide code, thx!
0
Comment
Question by:sehenkel
  • 2
3 Comments
 
LVL 7

Expert Comment

by:suramsureshbabu
ID: 12523179
0
 
LVL 26

Accepted Solution

by:
Hilaire earned 600 total points
ID: 12523382
You can re-use this ASP.Net code in your ASP application, using a CCW (Com Component Wrapper). The idea is to register the assembly with regAsm.exe to use it as if it were a Com Object or an ActiveX
To do this

- create a new class library in visual studio .net 2003
- add the required imports statements
inside the class paste the code your provided above for the public function isAuthenticated
- compile the class as a dll assembly (release version)
- copy the dll to the windows\system32 directory
- use the Visual Studio .net 2003 command prompt and run
regAsm c:\windows\system32\YourAssembly.dll

then in you ASP code you can write

dim obj
set obj = Server.CreateObject("YourAssembly.YourClassName")
if obj.IsAuthenticated(user, password) then
   .....
end if
set obj = nothing

HTH

Hilaire
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question