code: function onReferralChase(ref) {
      var index = 0;
      var referralUrl;
      // Loop over the referrals received.
      while (referralUrl = (ref.uris || [])[index++]) {
        if (isAllowedReferral(referralUrl)) {
          log.debug('Following LDAP referral chase at %s', referralUrl);
          var referralClient = createClient.call(self, referralUrl, opts);
          pendingReferrals.push(referralClient);
  
          var referral = Url.parse(referralUrl);
          var referralBaseDn = (referral.pathname || '/').substring(1);
          referralClient.search(referralBaseDn, getLdapOpts(opts), controls, function(err, res) {
            /**
             * Occurs when a error is encountered with the referral client.
             * @param {Object} err The error object or string.
             */
            function onReferralError(err) {
              log.error(err, '[%s] An error occurred chasing the LDAP referral on %s (%j)',
                       (err || {}).errno, referralBaseDn, opts);
              removeReferral(referralClient);
            }
            // If the referral chase / search failed, fail silently.
            if (err) {
              onReferralError(err);
              return;
            }
  
            res.on('searchEntry', onSearchEntry);
            res.on('searchReference', onReferralChase);
            res.on('error', onReferralError);
            res.on('end', function(result) {
              removeReferral(referralClient);
              onSearchEnd();
            });
          });
        }
      }
    }
docs: Occurs when a search reference / referral is received. Follows the referral chase if
  enabled.
  @param {Object} ref The referral.