LDAP Search

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good Day Folks,

I'm still trying to write a class to do LDAP searches on a Novell
eDirectory. I've yet to see anything that even compiles, this includes
samples from MSDN. Amazing. I appreciate the help I'm getting from
individuals, but it would be nice if someone from Microsoft helped also. It
is after all their product.

Anyways, below is the class, ASPX file, and the compiler error message.

Any ideas ?
Thanks in advance
/Serge

LDAP Authentication Class
------------------------------

<script language="VB" runat="server">

Public Class LdapAuthentication

Private _path As String
Private _ldapDirlisting as string

Public oSearchResult As SearchResult

Public Property ldapDirlisting As String
Get
Return _ldapDirlisting
End Get

Set(ByVal Value As String)
_ldapDirlisting = Value
End Set
End Property


Public Sub New(ByVal path As String)
_path = path
_ldapDirlisting=Nothing
End Sub


Sub GetDirectoryEntries()

dim oConnection As New DirectoryEntry(_path)
dim oSearcher As New DirectorySearcher(oConnection)
oSearcher.Filter = "(objectClass=user)"

dim oSearchResult As SearchResult

For Each oSearchResult In oSearcher.FindAll()
_ldapDirlisting &= oSearchResult.Properties("name").ToString &
","
Next

End Sub

End Class

</script>

End of LDAP Authentication Class


ASPX File which calls the class
-----------------------------------

<%@ Page Language="vb" AutoEventWireup="false"
CompilerOptions='/R:"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\system.directoryservices.dll"' Debug="true" %>

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.DirectoryServices" %>

<!--#include file="LDAPAuthentication2.vb"-->

<html>
<head>
<title></title>
</head>
<body>

<%
Const LDAPPath As String = "LDAP://grnbds2.ocdsb.edu.on.ca/ou=GREENBANK,
ou=DIST5, o=OCDSB"

dim myldap as LdapAuthentication=new LdapAuthentication(LDAPPath)

myldap.GetDirectoryEntries()

response.write(myldap.ldapDirlisting)
%>
</body>
</html>

End of ASPX File which calls the class

Compiler Error Message

System.NullReferenceException: Object reference not set to an instance of an
object. Line 36

Line 35: For Each oSearchResult In oSearcher.FindAll()
Line 36: _ldapDirlisting &= oSearchResult.Properties("name").ToString & ","
Line 37: Next


--
 
There is an amazing lack of information/ideas in dealing with LDAP data
sources under VS2005. I've been looking constantly but everyone is so
enamered with the new datalink stuff there is no reference to what it DOES
NOT deal with (LDAP). Also all my old methodoliges are now broken.

Anyone that does LDAP queries on a regular basis and have some
reccomendations for best practices or sample code under VS2005? There is a
huge void in this area right at the moment.
 
Back
Top