Ejemplo n.º 1
0
func (self *Ldap) StartTLS() error {
	var ctrls **C.LDAPControl = nil
	var ctrls2 **C.LDAPControl = nil
	rv := C.ldap_start_tls_s(self.conn, ctrls, ctrls2)

	if rv == LDAP_OPT_SUCCESS {
		return nil
	}
	self.conn = nil
	return errors.New(fmt.Sprintf("LDAP::StartTLS() error (%d) : %s", int(rv), ErrorToString(int(rv))))
}
Ejemplo n.º 2
0
/*
 * StartTLS() is used for regular LDAP (not
 * LDAPS) connections to establish encryption
 * after the session is running.
 *
 * return value :
 *  - nil on success,
 *  - error with error description on error.
 */
func (self *Ldap) StartTLS() error {
	var rv int

	// API: int ldap_start_tls_s(LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls);
	rv = int(C.ldap_start_tls_s(self.conn,
		C.to_ldapctrlptr(unsafe.Pointer(nil)),
		C.to_ldapctrlptr(unsafe.Pointer(nil))))

	if rv == LDAP_OPT_SUCCESS {
		return nil
	}

	return errors.New(fmt.Sprintf("LDAP::StartTLS() error (%d) : %s", rv,
		ErrorToString(rv)))
}