从here阅读LDAP身份验证教程并从here搞乱相关示例代码时,我发现有一个函数可以处理WL中的登录失败。 Client.invokeProcedure。 ( 更新:不,onFailure不用于处理登录失败 )。
在示例中,onSuccess和onFailure都调用相同的函数。如果LDAP登录失败,我修改了onFailure部分以调用另一个函数。 onSuccess部分工作正常,但onFailure永远不会被调用。相反,密码字段只是空白,控制台也不会打印我创建的错误消息。
我不确定为什么会发生这种情况,还有其他需要配置的东西吗?
这是来自LDAPApp.js的代码:
function getSecretData(){
WL.Logger.debug("@getSecretData");
var invocationData = {
adapter: "DummyAdapter",
procedure: "getSecretData_Success",
parameters: []
};
WL.Client.invokeProcedure(invocationData, {
onSuccess: getSecretData_Callback_Success,
onFailure: getSecretData_Callback_Fail,
invocationContext: {}
});
}
function getSecretData_Callback_Success(response){
var UserName = WL.Client.getLoginName("LDAPRealm");
$("#resultDiv").html(new Date() + "<hr/>");
$("#resultDiv").append("Secret data :: " + response.invocationResult.loginStatus + " " + UserName);
}
function getSecretData_Callback_Fail(response){
WL.Logger.error("Error place");
$("#resultDiv").html(new Date() + "<hr/>");
$("#resultDiv").append("Fail !! :: " + response.invocationResult.secretData);
}
这是来自适配器DummyAdapter-impl.js的代码:
function getSecretData_Success(){
WL.Logger.debug("@getSecretData_Success");
return {loginStatus: "1_Login Success ! "};
}
function getSecretData_Fail(){
WL.Logger.debug("@getSecretData_Fail");
return {secretData: "Login Fail !"};
}
5月26日更新&#39; 14 :onFailure不用于检测登录失败。您将再次受到挑战,在我的情况下将发生在LDAPRealmChallengeHandler.handleChallenge部分。由个人来处理这些错误。希望这有助于每个人。
答案 0 :(得分:0)
您无法在适配器AFAIK中使用失败功能。
`The failure handler of this call is called in two cases:
The procedure was called but failed. In this case, the invocationResult property is added to the response received by the failure handler. This property has the same structure as the invocationResult property returned to the success handler, but the value of the isSuccessful attribute is false. For the structure of the invocationResult property, see invocationResult.
A technical failure resulted in the procedure not being called. In this case, the failure handler receives a standard response object.`