open method
Opens the network connection to the LDAP directory server.
Returns a Future which completes when the connection is ready for use. Throws subclasses of LdapException.
/// ## Exceptions
- LdapSocketException when an error with the underlying socket.
- LdapSocketServerNotFoundException when the server cannot be found. Check the hostname is correct.
- LdapSocketRefusedException when the port on the server cannot be connected to. Check LDAP is running on the server and the port number is correct.
- StateError if the connection is already opened (i.e. it can't be re-opened without first closing it).
- Other exceptions might also be thrown.
Implementation
Future<void> open() async {
loggerConnection.fine('open: $url');
switch (state) {
case ConnectionState.closed:
await _cmgr.connect();
state = ConnectionState.ready;
return;
default:
throw StateError('Attempt to open connection that is already opened');
}
}