code: func (auth *Auth) Dial() error {
  	if hookDial != nil {
  		return hookDial(auth)
  	}
  
  	var err error
  	var certPool *x509.CertPool
  	if auth.server.RootCACert != "" {
  		certPool = x509.NewCertPool()
  		for _, caCertFile := range strings.Split(auth.server.RootCACert, " ") {
  			pem, err := ioutil.ReadFile(caCertFile)
  			if err != nil {
  				return err
  			}
  			if !certPool.AppendCertsFromPEM(pem) {
  				return errors.New("Failed to append CA certificate " + caCertFile)
  			}
  		}
  	}
  	var clientCert tls.Certificate
  	if auth.server.ClientCert != "" && auth.server.ClientKey != "" {
  		clientCert, err = tls.LoadX509KeyPair(auth.server.ClientCert, auth.server.ClientKey)
  		if err != nil {
  			return err
  		}
  	}
  	for _, host := range strings.Split(auth.server.Host, " ") {
  		address := fmt.Sprintf("%s:%d", host, auth.server.Port)
  		if auth.server.UseSSL {
  			tlsCfg := &tls.Config{
  				InsecureSkipVerify: auth.server.SkipVerifySSL,
  				ServerName:         host,
  				RootCAs:            certPool,
  			}
  			if len(clientCert.Certificate) > 0 {
  				tlsCfg.Certificates = append(tlsCfg.Certificates, clientCert)
  			}
  			if auth.server.StartTLS {
  				auth.conn, err = dial("tcp", address)
  				if err == nil {
  					if err = auth.conn.StartTLS(tlsCfg); err == nil {
  						return nil
  					}
  				}
  			} else {
  				auth.conn, err = LDAP.DialTLS("tcp", address, tlsCfg)
  			}
  		} else {
  			auth.conn, err = dial("tcp", address)
  		}
  
  		if err == nil {
  			return nil
  		}
  	}
  	return err
  }
docs: // Dial dials in the LDAP