BBjLDAPConnection::search

Description

In BBj 11.0 and higher, this method executes an LDAP search query on the LDAP server and returns a list of the entries that match the search criteria.

Syntax

Return Value

Method

BBjLDAPConnection

search(string baseDN, int scope, int sizeLimit, int timeLimit, string filter)

Parameters

Parameter

Description

baseDN

Full DN (distinguished name) which points to the LDAP entry whose child entries should be searched.

scope

The scope that specifies the range of entries that should be examined for the search. Valid values are BBjLDAPSearchResult.SCOPE_ONE, BBjLDAPSearchResult.SCOPE_BASE, BBjLDAPSearchResult.SCOPE_SUB, and BBjLDAPSearchResult.SCOPE_SUBORDINATE_SUBTREE. See BBjLDAPSearchResult for further details.

sizeLimit

The maximum number of results to return from the query. A value of zero indicates that there should be no limit.

timeLimit

The maximum length of time in seconds that the server should spend processing this search request. A value of zero indicates that there should be no limit.

filter

The string representation of the filter to use to identify matching entries. It must not be null. The format of this string follows standard LDAP search filter syntax.

Return Value

Returns BBjLDAPSearchResult object which contains information regarding the request.

Remarks

None.

Example

rem ' getLDAPConnection sample 1

use com.basis.bbj.proxies.ldap.BBjLDAPSearchResult
use com.basis.bbj.proxies.ldap.BBjLDAPConnection

declare BBjLDAPConnection ldapCon!
declare BBjLDAPSearchResult searchResults!
declare BBjVector entries!
declare BBjVector attrs!

rem 'Get a connection to a specific LDAP server
host$ = "localhost"
port = 10389
authDN$ = "uid=admin,ou=system"
pwd$ = "secret"
ldapCon! = BBjAPI().getLDAPConnection(host$, port, authDN$, pwd$)

rem 'return a list of all immediate children of the ou=system object
searchResults! = ldapCon!.search("ou=system",BBjLDAPSearchResult.SCOPE_ONE, 100, 100, "(objectClass=*)")
entries! = searchResults!.getSearchEntries()
for e = 0 to entries!.size() - 1
    entry! = entries!.getItem(e)
    print "ENTRY - dn: " + entry!.getDN()
    attrs! = entry!.getAttributeNames()
    for i = 0 to attrs!.size() - 1
        attr$ = attrs!.getItem(i)
        print "     " + attr$
    next i
next e

rem 'Unbind and close the connection
ldapCon!.close()

See Also

BBjAPI

BBjLDAPConnection

BBjLDAPSearchResult

BBj Object Diagram for an illustration of the relationship between BBjObjects