> $adapter = Zend_Auth_Adapter_DbTable();
> $adapter->setTableName('user')
> ->setIdentityColumn('username')
> ->setCredentialColumn('password')
> ->setCredentialTreatment('md5(?) and system_id = 20')
> ->setIdentity('renanbr')
> ->setCredential('123');
> $result = Zend_Auth::getInstance()->authenticate($adapter)->isValid();
>
> $result is false, the error code is
> Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS, but just one row has
> "zend_auth_credential_match = 1"
>
This is an interesting use case. I would say that your 'identity', in
this case, is actually the combination of both the username and the
system_id. The way you are describing it above is that the combination
of the password and system_id makes up the credential (which is
conceptually not what you want.)
One thing you could do is get the select object to further identify the
proper identity. So, assuming your code above, it might look like this:
$adapter = Zend_Auth_Adapter_DbTable();
$adapter->setTableName('user')
->setIdentityColumn('username')
->setCredentialColumn('password')
->setCredentialTreatment('md5(?)')
->setIdentity('renanbr')
->setCredential('123')
// add a where clause to the internal select object
$adapter->getDbSelect()->where('system_id = 20');
$result = Zend_Auth::getInstance()->authenticate($adapter)->isValid();
I am pretty sure that will remove the ambiguity from the identity clause
at authenticate() time.
Hope this helps,
Ralph Schindler
没有评论:
发表评论