* Rename fsldap to efsldap
* Use gopkg.in/ini.v1 over github.com/joho/godotenv * Fix typos Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
@@ -3,6 +3,18 @@ package utils
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"git.laidback.moe/YakumoLabs/efsldap/config"
|
||||
)
|
||||
|
||||
var (
|
||||
Base = config.Config.LDAPBase
|
||||
Domain = config.Config.SMTPDomain
|
||||
Uid = config.Config.LDAPUID
|
||||
)
|
||||
|
||||
var (
|
||||
BaseLength = len(Base) + 1
|
||||
UidLength = len(Uid) + 1
|
||||
)
|
||||
|
||||
func GetMail(user string) string {
|
||||
@@ -14,11 +26,11 @@ func GetLdapName(user string) string {
|
||||
}
|
||||
|
||||
func GetUser(name string) string {
|
||||
endIndex := len(name) - BaseLenght
|
||||
endIndex := len(name) - BaseLength
|
||||
if endIndex < 0 {
|
||||
return ""
|
||||
}
|
||||
user := name[UidLenght:endIndex]
|
||||
user := name[UidLength:endIndex]
|
||||
|
||||
user = strings.TrimSuffix(user, "@"+Domain)
|
||||
|
||||
@@ -26,7 +38,7 @@ func GetUser(name string) string {
|
||||
}
|
||||
|
||||
func GetSearchUser(name string) string {
|
||||
startIndex := UidLenght + 1
|
||||
startIndex := UidLength + 1
|
||||
endIndex := len(name) - 1
|
||||
if endIndex < 0 {
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user