// Code fragment to upgrade an LDAP connection to TLS

try{
        var ctx = thisConnector.connector.getLdapContext();
        tls = ctx.extendedOperation(new
            Packages.javax.naming.ldap.StartTlsRequest());

        task.logmsg("Negotiating TLS");
        tls.negotiate();
        task.logmsg("TLS OK");
} catch (E) {

        task.logmsg("TLS negotiation FAILED");
        task.logmsg(E);
        tls.close();
        tls=null;
        system.abortAssemblyLine("TLS negotiation FAILED")
}
