basic implementation of create/delete pool
This commit is contained in:
39
app/ldap/utils.go
Normal file
39
app/ldap/utils.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package ldap
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
|
||||
common "user-manager-api/app/common"
|
||||
)
|
||||
|
||||
func LDAPEntryToUser(entry *ldap.Entry) common.User {
|
||||
return common.User{
|
||||
CN: entry.GetAttributeValue("cn"),
|
||||
SN: entry.GetAttributeValue("sn"),
|
||||
Mail: entry.GetAttributeValue("mail"),
|
||||
}
|
||||
}
|
||||
|
||||
func LDAPEntryToGroup(entry *ldap.Entry) common.Group {
|
||||
return common.Group{}
|
||||
}
|
||||
|
||||
func ParseLDAPError(err error) gin.H {
|
||||
if err != nil {
|
||||
LDAPerr := err.(*ldap.Error)
|
||||
return gin.H{
|
||||
"ok": false,
|
||||
"code": LDAPerr.ResultCode,
|
||||
"result": ldap.LDAPResultCodeMap[LDAPerr.ResultCode],
|
||||
"message": LDAPerr.Err.Error(),
|
||||
}
|
||||
} else {
|
||||
return gin.H{
|
||||
"ok": true,
|
||||
"code": 200,
|
||||
"result": "OK",
|
||||
"message": "",
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user