dartdap 0.5.0 copy "dartdap: ^0.5.0" to clipboard
dartdap: ^0.5.0 copied to clipboard

outdated

LDAP v3 client library for Dart. Supports basic LDAP operations, add, delete, search, modify against any LDAP v3 compliant server.

example/main.dart

import 'dart:async';

import 'package:dartdap/dartdap.dart';
import 'package:logging/logging.dart';


Future<void> main() async {
  Logger.root.onRecord.listen((LogRecord r) {
    print(
        '${r.time}: ${r.loggerName}: ${r.level.name}: ${r.message}');
  });

  Logger.root.level = Level.FINE;

  await example();
}


var base = 'ou=people,ou=identities';
var filter = Filter.present('objectClass');
var attrs = ['dn','objectclass'];

Future example() async {
  var host = 'localhost';
  var bindDN = 'uid=admin';
  var password = 'SomePassword';

  var connection = LdapConnection(host: host, ssl: false, port: 1389,
  bindDN:  bindDN, password:  password);


  try {
    // Perform search operation
    await connection.bind();
    print('Bind OK');

    print('******* before search');

    await _doSearch(connection);

    print('******* after search');

  } catch (e, stacktrace) {
    print('********* Exception: $e $stacktrace');

  } finally {
    // Close the connection when finished with it
    print('Closing!!! ');
    await connection.close();
  }
}

Future<void>_doSearch(LdapConnection connection) async {
  var searchResult = await connection.search(base, filter, attrs, sizeLimit:  5);
  print('Search returned ${searchResult.stream}');

  await for (var entry in searchResult.stream) {
    // Processing stream of SearchEntry
    print('dn: ${entry.dn}');

    // Getting all attributes returned

    for (var attr in entry.attributes.values) {
      for (var value in attr.values) {
        // attr.values is a Set
        print('  ${attr.name}: $value');
      }
    }
  }

}
13
likes
0
pub points
84%
popularity

Publisher

unverified uploader

LDAP v3 client library for Dart. Supports basic LDAP operations, add, delete, search, modify against any LDAP v3 compliant server.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

asn1lib, collection, logging, petitparser

More

Packages that depend on dartdap