Compare commits
No commits in common. "6ef99788391d792bbd76d2b910b02f43f919e94d" and "b0d006b39b37d7d767d84cacb9d6227be66b223f" have entirely different histories.
6ef9978839
...
b0d006b39b
2
ldap.go
2
ldap.go
@ -98,7 +98,7 @@ func internalLdapSearch(conLdap *MyLdap, searchReq *ldap.SearchRequest, attempt
|
|||||||
func searchByCn(myldap *MyLdap, baseDn, cn, class, attributes string) (*ldap.SearchResult, error) {
|
func searchByCn(myldap *MyLdap, baseDn, cn, class, attributes string) (*ldap.SearchResult, error) {
|
||||||
var filter string
|
var filter string
|
||||||
if false == strings.EqualFold(cn, "ALL") {
|
if false == strings.EqualFold(cn, "ALL") {
|
||||||
filter = fmt.Sprintf("cn=%s", cn)
|
filter = fmt.Sprintf("(cn=%s)", cn)
|
||||||
} else {
|
} else {
|
||||||
filter = cn
|
filter = cn
|
||||||
}
|
}
|
||||||
|
16
main.go
16
main.go
@ -22,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
gVersion = "0.5.8"
|
gVersion = "0.5.6"
|
||||||
|
|
||||||
gRoLdap *MyLdap
|
gRoLdap *MyLdap
|
||||||
)
|
)
|
||||||
@ -263,7 +263,6 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, nil)
|
c.AbortWithError(http.StatusInternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer ldapCon.Conn.Close()
|
|
||||||
|
|
||||||
// json format is the default
|
// json format is the default
|
||||||
format := c.DefaultQuery("format", "json")
|
format := c.DefaultQuery("format", "json")
|
||||||
@ -299,7 +298,6 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, nil)
|
c.AbortWithError(http.StatusInternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer ldapCon.Conn.Close()
|
|
||||||
|
|
||||||
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, "ALL")
|
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, "ALL")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -336,7 +334,6 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, nil)
|
c.AbortWithError(http.StatusInternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer ldapCon.Conn.Close()
|
|
||||||
|
|
||||||
res, err := searchByCn(ldapCon, ou, cn, class, attr)
|
res, err := searchByCn(ldapCon, ou, cn, class, attr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -368,7 +365,6 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, nil)
|
c.AbortWithError(http.StatusInternalServerError, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer ldapCon.Conn.Close()
|
|
||||||
|
|
||||||
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, attr)
|
modified, err := checkIfModifiedSince(c, ldapCon, ou, cn, class, attr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -409,7 +405,6 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, err)
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer ldapCon.Conn.Close()
|
|
||||||
|
|
||||||
// Unmarshall json body to a map
|
// Unmarshall json body to a map
|
||||||
if c.Request.Header.Get("Content-Type") == "application/json" {
|
if c.Request.Header.Get("Content-Type") == "application/json" {
|
||||||
@ -473,7 +468,6 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, err)
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer ldapCon.Conn.Close()
|
|
||||||
|
|
||||||
// Unmarshall json body to a map
|
// Unmarshall json body to a map
|
||||||
if c.Request.Header.Get("Content-Type") == "application/json" {
|
if c.Request.Header.Get("Content-Type") == "application/json" {
|
||||||
@ -527,7 +521,6 @@ func initRouter(r *gin.Engine) {
|
|||||||
c.AbortWithError(http.StatusInternalServerError, err)
|
c.AbortWithError(http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer ldapCon.Conn.Close()
|
|
||||||
|
|
||||||
// Unmarshall json body to a map
|
// Unmarshall json body to a map
|
||||||
if c.Request.Header.Get("Content-Type") == "application/json" {
|
if c.Request.Header.Get("Content-Type") == "application/json" {
|
||||||
@ -577,7 +570,6 @@ func main() {
|
|||||||
var tlsCert string
|
var tlsCert string
|
||||||
var doTls bool
|
var doTls bool
|
||||||
var debug bool
|
var debug bool
|
||||||
var showversion bool
|
|
||||||
|
|
||||||
flag.StringVar(&confFile, "config", "", "Path to the config file (optional)")
|
flag.StringVar(&confFile, "config", "", "Path to the config file (optional)")
|
||||||
flag.StringVar(&listen, "listen-addr", "0.0.0.0:8080", "listen address for server")
|
flag.StringVar(&listen, "listen-addr", "0.0.0.0:8080", "listen address for server")
|
||||||
@ -590,15 +582,9 @@ func main() {
|
|||||||
flag.StringVar(&tlsPrivKey, "ssl-private-key", "", "SSL Private key")
|
flag.StringVar(&tlsPrivKey, "ssl-private-key", "", "SSL Private key")
|
||||||
flag.StringVar(&tlsCert, "ssl-certificate", "", "SSL certificate (PEM format)")
|
flag.StringVar(&tlsCert, "ssl-certificate", "", "SSL certificate (PEM format)")
|
||||||
flag.BoolVar(&debug, "debug", false, "Set log level to debug")
|
flag.BoolVar(&debug, "debug", false, "Set log level to debug")
|
||||||
flag.BoolVar(&showversion, "version", false, "Show version then exit")
|
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if showversion {
|
|
||||||
fmt.Printf("GlApi v%s\n", gVersion)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(confFile) > 0 {
|
if len(confFile) > 0 {
|
||||||
viper.SetConfigFile(confFile)
|
viper.SetConfigFile(confFile)
|
||||||
if err := viper.ReadInConfig(); err != nil {
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user