-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathldapmanager.go
66 lines (54 loc) · 1.56 KB
/
ldapmanager.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package pkg
import (
log "github.com/sirupsen/logrus"
ldapconfig "github.com/romnn/ldap-manager/pkg/config"
ldappool "github.com/romnn/ldap-manager/pkg/pool"
)
// LDAPManager implements the LDAP manager functionality
type LDAPManager struct {
ldapconfig.Config
Pool ldappool.Pool
GroupsDN string
UserGroupDN string
GroupsOU string
UsersOU string
DefaultUserGroup string
DefaultAdminGroup string
DefaultUserShell string
DefaultAdminUsername string
DefaultAdminPassword string
ForceCreateAdmin bool
GroupMembershipAttribute string
AccountAttribute string
GroupAttribute string
GroupMembershipUsesUID bool
}
// NewLDAPManager creates a new LDAPManager
func NewLDAPManager(config ldapconfig.Config) *LDAPManager {
log.SetFormatter(&log.TextFormatter{
DisableQuote: true,
})
return &LDAPManager{
Config: config,
GroupsDN: "ou=groups," + config.BaseDN,
UserGroupDN: "ou=users," + config.BaseDN,
GroupsOU: "groups",
UsersOU: "users",
DefaultUserGroup: "users",
DefaultAdminGroup: "admins",
DefaultUserShell: "/bin/bash",
GroupMembershipAttribute: "uniqueMember", // uniqueMember or memberUID
AccountAttribute: "uid",
GroupAttribute: "gid",
GroupMembershipUsesUID: false,
DefaultAdminUsername: "admin",
DefaultAdminPassword: "admin",
ForceCreateAdmin: false,
}
}
// Close closes the LDAP connection
func (m *LDAPManager) Close() {
if m.Pool != nil {
m.Pool.Close()
}
}