search method
Future<SearchResult>
search(
- String baseDN,
- Filter filter,
- List<
String> attributes, { - int scope = SearchScope.SUB_LEVEL,
- int sizeLimit = 0,
- List<
Control> controls = const <Control>[],
override
Performs an LDAP search operation.
Searches for LDAP entries, starting at the baseDN
,
specified by the search filter
, and obtains the listed attributes
.
The scope
of the search defaults to SUB_LEVEL (i.e.
search at base DN and all objects below it) if it is not provided.
The sizeLimit
defaults to 0 (i.e. no limit).
An optional list of controls
can also be provided.
Example:
var base = 'dc=example,dc=com';
var filter = Filter.present('objectClass');
var attrs = ['dc', 'objectClass'];
var sr = await connection.search(base, filter, attrs);
await for (var entry in sr.stream) {
// process the entry (SearchEntry)
// entry.dn = distinguished name (String)
// entry.attributes = attributes returned (Map<String,Attribute>)
}
Implementation
@override
Future<SearchResult> search(
String baseDN, Filter filter, List<String> attributes,
{int scope = SearchScope.SUB_LEVEL,
int sizeLimit = 0,
List<Control> controls = const <Control>[]}) async {
LdapConnection? c;
try {
c = await getConnection();
var sr = await c.search(baseDN, filter, attributes,
scope: scope, sizeLimit: sizeLimit, controls: controls);
return sr;
} catch (e, stacktrace) {
loggerPool.severe('search error $e. Stack $stacktrace', stacktrace);
rethrow;
} finally {
if (c != null) {
await releaseConnection(c);
}
}
}