LdapConnection constructor

LdapConnection({
  1. String host = 'localhost',
  2. bool ssl = false,
  3. int port = Ldap.PORT_LDAP,
  4. String bindDN = '',
  5. String password = '',
  6. BadCertHandlerType badCertificateHandler = defaultBadCertHandler,
  7. SecurityContext? context,
})

Constructor for an LDAP connection to an LDAP directory server.

The connection is set to use ssl (or not) to connect to port at host, and optionally authenticated to bindDN with password.

The badCertHandler is set to badCertificateHandler. If null, a LdapCertificateException is thrown if the certificate is bad.

Exceptions

  • ArgumentError when parameters are incorrect: host, bindDN or password is not a String or null; or port is not an int or null.
  • StateError when the connection is currently open and the host, port, or ssl is changed. Close the connection before making changes.

Implementation

LdapConnection(
    {String host = 'localhost',
    bool ssl = false,
    int port = Ldap.PORT_LDAP,
    String bindDN = '',
    String password = '',
    BadCertHandlerType badCertificateHandler = defaultBadCertHandler,
    SecurityContext? context})
    : _host = host,
      _port = port,
      _bindDN = bindDN,
      _password = password,
      _isSSL = ssl,
      _badCertHandler = badCertificateHandler {
  _cmgr = ConnectionManager(this, tlsSecurityContext: _context);
}