Don't use Ldap as reference

merge-requests/6/head
meskio 5 years ago
parent 70aa8aa747
commit 30d21af189
Signed by: meskio
GPG Key ID: 52B8F5AC97A2DA86
  1. 12
      ldap/user.go

@ -20,7 +20,7 @@ type User struct {
}
// ValidateUser in the ldap
func (l *Ldap) ValidateUser(user string, pass string) error {
func (l Ldap) ValidateUser(user string, pass string) error {
conn, err := l.login(user, pass)
if err == nil {
conn.Close()
@ -29,7 +29,7 @@ func (l *Ldap) ValidateUser(user string, pass string) error {
}
// ChangePass changes logged in user's password
func (l *Ldap) ChangePass(user string, oldpass string, newpass string) error {
func (l Ldap) ChangePass(user string, oldpass string, newpass string) error {
if oldpass == "" {
return errors.New("Old password can not be empty")
}
@ -51,7 +51,7 @@ func (l *Ldap) ChangePass(user string, oldpass string, newpass string) error {
}
//GetUser returns the user data
func (l *Ldap) GetUser(name string) (User, error) {
func (l Ldap) GetUser(name string) (User, error) {
conn, err := l.connect()
if err != nil {
return User{}, err
@ -66,7 +66,7 @@ func (l *Ldap) GetUser(name string) (User, error) {
}
//ListUsers returns a list of all users in the ldap
func (l *Ldap) ListUsers() ([]User, error) {
func (l Ldap) ListUsers() ([]User, error) {
conn, err := l.connect()
if err != nil {
return nil, err
@ -138,7 +138,7 @@ func (l Ldap) DelUser(user string) error {
return l.del(dn)
}
func (l *Ldap) login(user string, password string) (*ldap.Conn, error) {
func (l Ldap) login(user string, password string) (*ldap.Conn, error) {
conn, err := l.connect()
if err != nil {
return nil, err
@ -152,7 +152,7 @@ func (l *Ldap) login(user string, password string) (*ldap.Conn, error) {
return conn, conn.Bind(userdn, password)
}
func (l *Ldap) searchUser(user string, conn *ldap.Conn) (entry *ldap.Entry, err error) {
func (l Ldap) searchUser(user string, conn *ldap.Conn) (entry *ldap.Entry, err error) {
searchRequest := ldap.NewSearchRequest(
"ou=people,"+l.DC,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,

Loading…
Cancel
Save