|
@@ -1,7 +1,9 @@
|
|
|
package config
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
"io/ioutil"
|
|
|
+ "strings"
|
|
|
|
|
|
yaml "gopkg.in/yaml.v2"
|
|
|
)
|
|
@@ -16,6 +18,7 @@ type ConfigT struct {
|
|
|
|
|
|
// Domain
|
|
|
|
|
|
+ Url string
|
|
|
Domain string
|
|
|
|
|
|
// Logging
|
|
@@ -45,6 +48,33 @@ type ConfigT struct {
|
|
|
AutoMigrate bool
|
|
|
Regenerate bool
|
|
|
}
|
|
|
+
|
|
|
+ Ldap struct {
|
|
|
+ Host string
|
|
|
+ Domain string
|
|
|
+
|
|
|
+ AdminCN string `yaml:"admin_cn"`
|
|
|
+ AdminPassword string `yaml:"admin_password"`
|
|
|
+
|
|
|
+ TeachersDN string `yaml:"teachers_dn"`
|
|
|
+ PeopleDN string `yaml:"people_dn"`
|
|
|
+ GroupsDN string `yaml:"groups_dn"`
|
|
|
+
|
|
|
+ MailGIDNumber string `yaml:"mail_gid_number"`
|
|
|
+ FirstUIDNumber string `yaml:"first_uid_number"`
|
|
|
+
|
|
|
+ MailDirBasePath string `yaml:"maildir_base_path"`
|
|
|
+ MailQuota string `yaml:"mail_quota"`
|
|
|
+ }
|
|
|
+
|
|
|
+ Smtp struct {
|
|
|
+ Host string
|
|
|
+ Port int
|
|
|
+ Username string
|
|
|
+ Password string
|
|
|
+ From string
|
|
|
+ Cc string
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
var Config *ConfigT
|
|
@@ -72,3 +102,14 @@ func Read(data []byte, config *ConfigT) error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+func (conf *ConfigT) DomainDN() (out string) {
|
|
|
+ for _, dc := range strings.Split(conf.Domain, ".") {
|
|
|
+ out += "dc=" + dc + ","
|
|
|
+ }
|
|
|
+ return strings.TrimRight(out, ",")
|
|
|
+}
|
|
|
+
|
|
|
+func (conf *ConfigT) AdminCN() string {
|
|
|
+ return fmt.Sprintf("cn=%s,%s", conf.Ldap.AdminCN, conf.DomainDN())
|
|
|
+}
|