dartdap 0.4.3 copy "dartdap: ^0.4.3" to clipboard
dartdap: ^0.4.3 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';

Future example() async {
  // Create an LDAP connection object

  var host = "localhost";
  var ssl = false; // true = use LDAPS (i.e. LDAP over SSL/TLS)
  var port;      // null = use standard LDAP/LDAPS port
  var bindDN = "cn=Manager,dc=example,dc=com"; // null=unauthenticated
  var password = "p@ssw0rd";

  var connection = new LdapConnection(host: host);
  connection.setProtocol(ssl, port);
  await connection.setAuthentication(bindDN, password);

  try {
    // Perform search operation

    var base = "dc=example,dc=com";
    var filter = Filter.present("objectClass");
    var attrs = ["dc", "objectClass"];

    var count = 0;

    var searchResult = await connection.search(base, filter, attrs);
    await for (var entry in searchResult.stream) {
      // Processing stream of SearchEntry
      count++;
      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");
        }
      }

      // Getting a particular attribute

      assert(entry.attributes["dc"].values.length == 1);
      var dc = entry.attributes["dc"].values.first;
      print("# dc=$dc");
    }

    print("# Number of entries: ${count}");
  } catch (e) {
    print("Exception: $e");
  } finally {
    // Close the connection when finished with it
    await connection.close();
  }
}
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, quiver_hashcode

More

Packages that depend on dartdap