Beispiel #1
0
func (auth LDAPConnector) Authenticate(user, pass string) error {
	conn, err := ldap.DialTLS("tcp", auth.Address, &tls.Config{InsecureSkipVerify: true})
	if err != nil {
		return err
	}
	return conn.Bind(auth.BindPrefix+ldap.EscapeFilter(user)+auth.BindSuffix, pass)
}
Beispiel #2
0
func (auth LDAPConnector) ChangePass(user, oldpass, newpass string) error {
	conn, err := ldap.DialTLS("tcp", auth.Address, &tls.Config{InsecureSkipVerify: true})
	if err != nil {
		return err
	}
	err = conn.Bind(user, oldpass)
	if err != nil {
		return err
	}
	pmr := ldap.NewPasswordModifyRequest(user, oldpass, newpass)
	_, err = conn.PasswordModify(pmr)
	return err
}