LDAP search



Good Day Folks,

I'm trying to do LDAP searches, on a Novell eDirectory

I have an LDAP class defined as follows

' Contents of LDAPAuthentication.vb

<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
Return _ldapDirlisting
End Get

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

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

Sub GetDirectoryEntries()

dim oConnection As New DirectoryEntry(_path)
dim oSearcher As New DirectorySearcher(oConnection)
dim oSearchResults As SearchResultCollection()
oSearchResult=New SearchResult ' COMPILE ERROR IS HERE.

oSearcher.Filter = "(objectClass=user)"
oSearchResults = oSearcher.FindAll()

For Each oSearchResult In oSearchResults
_ldapDirlisting &= oSearchResult.Properties("name").ToString &

End Sub

End Class


' Contents of LDAPAuthentication.vb ends here


' Contents of ASP.NET script which calls the class listed above.

<%@ 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="LDAPAuthentication.vb"-->


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

dim myldap as LdapAuthentication=new LdapAuthentication(LDAPPath)



I'm getting the following error message

Compiler Error Message: BC30390:
'System.DirectoryServices.SearchResult.Private Sub New(parentCredentials As
System.Net.NetworkCredential, parentAuthenticationType As
System.DirectoryServices.AuthenticationTypes)' is not accessible in this
context because it is 'Private'.


The compiler is telling you that you cannot explicitely create a new
instance of the SearchResult class, because its constructor is private (thus
out of reach for your code).

As far as I can see from quickly looking at your code, you don't need to
create an instance of the class. Just a

Dim oSearchResult As SearchResult

should suffice.

The instances will be created automatically by the call to


Hope this helps

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question