LDAP Search

G

Guest

Good Day Folks,

I'm trying to do LDAP searches, on a Novell eDirectory. I made the change
someone suggested, but now I'm getting a differenct error.

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 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)
dim oSearchResults As SearchResultCollection()
dim oSearchResult As SearchResult

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

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

End Sub

End Class

</script>

' 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"-->

<html>
<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>

I'm getting the following error message

Compiler Error Message: BC30311: Value of type
'System.DirectoryServices.SearchResultCollection' cannot be converted to
'1-dimensional array of System.DirectoryServices.SearchResultCollection'.

--

Any ideas on how to correct this error and perform the LDAP search ?

Thanks in advance
/Serge
 
M

Marc Scheuner [MVP ADSI]

dim oSearchResults As SearchResultCollection()

I think this declares an ARRAY of SearchResultCOllections, no?? That's
really not what you want......anyway, it's totally unnecessary,
too....

Try this:
dim oSearchResult As SearchResult

oSearcher.Filter = "(objectClass=user)"

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

End Sub

End Class


That should do it, I hope

Marc
 

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

Top