update go-ldap to version 3

- Resolves: #13
merge-requests/4/head
Kali Kaneko 4 years ago
parent 36da1286d6
commit f3886e5161
  1. 10
      Makefile
  2. 4
      README.md
  3. 8
      ldap/group.go
  4. 2
      ldap/ldap.go
  5. 6
      ldap/user.go

@ -7,5 +7,15 @@ all:
clean:
rm -rf node_modules dist lowry
deps:
sudo apt install slapd ldap-utils
fixtures:
sudo ldapadd -Y EXTERNAL -H ldapi:// -f /etc/ldap/schema/misc.ldif
sudo slapadd -n 1 -l examples/data.ldif
demo:
./lowry -config examples/lowry.conf
test:
go test ./...

@ -1,8 +1,8 @@
Set up a testing environment:
```
sudo apt install slapd
sudo apt install slapd ldap-utils
sudo cp examples/sindominio.* /etc/ldap/schema/
sudo ldapadd -Y EXTERNAL -H ldapi:// -f /etc/ldap/schema/sindominio.ldif
sudo slapadd -Y EXTERNAL -H ldapi:// -f /etc/ldap/schema/sindominio.ldif
sudo slapadd -n 1 -l examples/data.ldif
```

@ -5,7 +5,7 @@ import (
"fmt"
"strconv"
"github.com/go-ldap/ldap"
"gopkg.in/ldap.v3"
)
// Group has the ldap data of the group
@ -92,7 +92,7 @@ func (l Ldap) AddGroup(group string) error {
defer conn.Close()
dn := l.groupDN(group)
addRequest := ldap.NewAddRequest(dn)
addRequest := ldap.NewAddRequest(dn, nil)
addRequest.Attribute("cn", []string{ldap.EscapeFilter(group)})
addRequest.Attribute("objectClass", []string{"top", "posixGroup"})
addRequest.Attribute("gidNumber", []string{strconv.Itoa(gid)})
@ -112,7 +112,7 @@ func (l Ldap) AddUserGroup(user string, group string) error {
}
defer conn.Close()
modifyRequest := ldap.NewModifyRequest(l.groupDN(group))
modifyRequest := ldap.NewModifyRequest(l.groupDN(group), nil)
modifyRequest.Add("memberUid", []string{ldap.EscapeFilter(user)})
return conn.Modify(modifyRequest)
}
@ -125,7 +125,7 @@ func (l Ldap) DelUserGroup(user string, group string) error {
}
defer conn.Close()
modifyRequest := ldap.NewModifyRequest(l.groupDN(group))
modifyRequest := ldap.NewModifyRequest(l.groupDN(group), nil)
modifyRequest.Delete("memberUid", []string{ldap.EscapeFilter(user)})
return conn.Modify(modifyRequest)
}

@ -6,7 +6,7 @@ import (
"strconv"
"strings"
"github.com/go-ldap/ldap"
"gopkg.in/ldap.v3"
)
// Ldap configuration

@ -8,7 +8,7 @@ import (
"strings"
"time"
"github.com/go-ldap/ldap"
"gopkg.in/ldap.v3"
)
var searchAttributes = []string{"dn", "uid", "uidNumber", "gidNumber", "loginShell", "homeDirectory", "mail", "authTimestamp", "sdRole", "sdLocked", "userPassword"}
@ -165,7 +165,7 @@ func (l *Ldap) AddUser(user string, pass string, gid int) error {
uid++
dn := l.userDN(user)
addRequest := ldap.NewAddRequest(dn)
addRequest := ldap.NewAddRequest(dn, nil)
addRequest.Attribute("uid", []string{ldap.EscapeFilter(user)})
addRequest.Attribute("cn", []string{ldap.EscapeFilter(user)})
addRequest.Attribute("sn", []string{ldap.EscapeFilter(user)})
@ -214,7 +214,7 @@ func (l Ldap) changeUser(user, attribute string, value []string) error {
}
defer conn.Close()
modifyRequest := ldap.NewModifyRequest(l.userDN(user))
modifyRequest := ldap.NewModifyRequest(l.userDN(user), nil)
modifyRequest.Replace(attribute, value)
return conn.Modify(modifyRequest)
}

Loading…
Cancel
Save