/* * close LDAP connexion * * return value : * - nil on succes, * - error with error description on error. * */ func (self *Ldap) Close() error { // DEPRECATED // API: int ldap_unbind(LDAP *ld) rv := C.ldap_unbind(self.conn) if rv == LDAP_OPT_SUCCESS { return nil } self.conn = nil return errors.New(fmt.Sprintf("LDAP::Close() error (%d) : %s", int(rv), ErrorToString(int(rv)))) }
/* * close LDAP connexion * * return value : * - nil on succes, * - error with error description on error. * */ func (self *Ldap) Close() error { // check to see if we have a connection before unbind // it will SIGABRT if bind is unsuccessful //and defer close is called if self.conn != nil { rv := C.ldap_unbind(self.conn) if rv == LDAP_OPT_SUCCESS { return nil } self.conn = nil return errors.New(fmt.Sprintf("LDAP::Close() error (%d) : %s", int(rv), ErrorToString(int(rv)))) } else { return errors.New("Has been closed before or an error has occured before") } }