Пример #1
0
func (a *GroupController) FindUserLdap(r *knot.WebContext) interface{} {
	r.Config.OutputType = knot.OutputJson
	payload := map[string]interface{}{}
	err := r.GetPayload(&payload)
	if err != nil {
		return helper.CreateResult(false, nil, err.Error())
	}

	addr := payload["Address"].(string)
	basedn := payload["BaseDN"].(string)
	filter := payload["Filter"].(string)
	username := payload["Username"].(string)
	password := payload["Password"].(string)
	var attr []string

	err = toolkit.Serde(payload["Attribute"], &attr, "json")
	if err != nil {
		return helper.CreateResult(false, err, "error")
	}

	param := toolkit.M{}

	param.Set("username", username)
	param.Set("password", password)
	param.Set("attributes", attr)

	arrm, err := acl.FindDataLdap(addr, basedn, filter, param)
	if err != nil {
		return helper.CreateResult(false, err, "error")
	}

	return helper.CreateResult(true, arrm, "success")
}
Пример #2
0
func (a *UserController) TestFindUserLdap(r *knot.WebContext) interface{} {
	r.Config.OutputType = knot.OutputJson
	payload := map[string]interface{}{}
	err := r.GetPayload(&payload)
	if err != nil {
		return helper.CreateResult(false, nil, err.Error())
	}

	addr := toolkit.ToString(payload["Address"])  //192.168.0.200:389
	basedn := toolkit.ToString(payload["BaseDN"]) //DC=eaciit,DC=local
	filter := toolkit.ToString(payload["Filter"]) //(&(objectclass=person)(objectclass=organizationalPerson)(cn=*))
	var attr []string

	err = toolkit.Serde(payload["Attribute"], &attr, "json")
	if err != nil {
		return helper.CreateResult(true, err, "error")
	}

	param := toolkit.M{}

	param.Set("username", toolkit.ToString(payload["Username"])) //Alip Sidik
	param.Set("password", toolkit.ToString(payload["Password"])) //Password.1
	// param.Set("attributes", []string{"cn", "givenName"})
	param.Set("attributes", attr)

	arrtkm, err := acl.FindDataLdap(addr, basedn, filter, param)
	if err != nil {
		return helper.CreateResult(true, err, "error")
	}
	return helper.CreateResult(true, arrtkm, "sukses")
}