|
@@ -31,7 +31,6 @@ type ldapHandler struct {
|
|
|
|
|
|
type Config struct {
|
|
|
Enabled bool `json:"enabled"`
|
|
|
- AutoRedirect bool `json:"auto_redirect"`
|
|
|
BindUsername string `json:"bind_username"`
|
|
|
BindPassword string `json:"bind_password"`
|
|
|
FQDN string `json:"fqdn"`
|
|
@@ -88,11 +87,6 @@ func (ldap *ldapHandler) ReadConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
common.SendTextResponse(w, "Invalid config value [key=enabled].")
|
|
|
return
|
|
|
}
|
|
|
- autoredirect, err := strconv.ParseBool(ldap.readSingleConfig("autoredirect"))
|
|
|
- if err != nil {
|
|
|
- common.SendTextResponse(w, "Invalid config value [key=autoredirect].")
|
|
|
- return
|
|
|
- }
|
|
|
//get the LDAP config from db
|
|
|
BindUsername := ldap.readSingleConfig("BindUsername")
|
|
|
BindPassword := ldap.readSingleConfig("BindPassword")
|
|
@@ -102,7 +96,6 @@ func (ldap *ldapHandler) ReadConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
//marshall it and return
|
|
|
config, err := json.Marshal(Config{
|
|
|
Enabled: enabled,
|
|
|
- AutoRedirect: autoredirect,
|
|
|
BindUsername: BindUsername,
|
|
|
BindPassword: BindPassword,
|
|
|
FQDN: FQDN,
|
|
@@ -230,25 +223,24 @@ func (ldap *ldapHandler) convertGroup(ldapUser *ldap.Entry) UserAccount {
|
|
|
func (ldap *ldapHandler) TestConnection(w http.ResponseWriter, r *http.Request) {
|
|
|
//marshall it and return the connection status
|
|
|
userList, err := ldap.getAllUser(10)
|
|
|
- log.Println(userList, err)
|
|
|
if err != nil {
|
|
|
- empty, err := json.Marshal(syncorizeUserReturnInterface{})
|
|
|
+ errMessage, err := json.Marshal(syncorizeUserReturnInterface{Error: err.Error()})
|
|
|
if err != nil {
|
|
|
- common.SendErrorResponse(w, "Error while marshalling information")
|
|
|
+ common.SendErrorResponse(w, "{\"error\":\"Error while marshalling information\"}")
|
|
|
return
|
|
|
}
|
|
|
- common.SendJSONResponse(w, string(empty))
|
|
|
+ common.SendJSONResponse(w, string(errMessage))
|
|
|
return
|
|
|
}
|
|
|
returnJSON := syncorizeUserReturnInterface{Userinfo: userList, Length: len(userList), Error: ""}
|
|
|
accountJSON, err := json.Marshal(returnJSON)
|
|
|
if err != nil {
|
|
|
- empty, err := json.Marshal(syncorizeUserReturnInterface{})
|
|
|
+ errMessage, err := json.Marshal(syncorizeUserReturnInterface{Error: err.Error()})
|
|
|
if err != nil {
|
|
|
- common.SendErrorResponse(w, "Error while marshalling information")
|
|
|
+ common.SendErrorResponse(w, "{\"error\":\"Error while marshalling information\"}")
|
|
|
return
|
|
|
}
|
|
|
- common.SendJSONResponse(w, string(empty))
|
|
|
+ common.SendJSONResponse(w, string(errMessage))
|
|
|
return
|
|
|
}
|
|
|
common.SendJSONResponse(w, string(accountJSON))
|