-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.go
52 lines (47 loc) · 1.17 KB
/
config.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
package config
import (
"fmt"
)
// Config contains the configuration of the LDAP server
type Config struct {
Host string
Port int
Protocol string
Organization string
Domain string
BaseDN string
AdminUsername string
AdminPassword string
ReadOnlyUser bool
ReadOnlyUsername string
ReadOnlyPassword string
ConfigPassword string
TLS bool
UseRFC2307BISSchema bool
}
// NewConfig creates a default LDAP configuration
func NewConfig() Config {
return Config{
Host: "localhost",
Port: 389,
Protocol: "ldap",
Organization: "Example Inc.",
Domain: "example.org",
BaseDN: "dc=example,dc=org",
AdminUsername: "admin",
AdminPassword: "admin",
ReadOnlyUser: true,
ReadOnlyUsername: "readonly",
ReadOnlyPassword: "readonly",
ConfigPassword: "config",
TLS: false,
UseRFC2307BISSchema: true,
}
}
// URI returns the connection URI for the LDAP config
func (cfg *Config) URI() string {
return fmt.Sprintf(
"%s://%s:%d",
cfg.Protocol, cfg.Host, cfg.Port,
)
}