Hi,
There are few ways which allows to implement this workflow.
The good example with simular workflow there is in DUO person authenticator [script](https://github.com/GluuFederation/oxAuth/blob/master/Server/integrations/duo/DuoExternalAuthenticator.py)
In lines 102-113 of this script we determine if user member of DUO group and change dynamically count of steps need to log in. You can add implement simular logic to CAS script to not redirect user to CAS server for authentication in order to process LDAP authentication.
Also there is alternative solution. You can enable both "basic" and "cas" person authenticator script. And write simple script and put your logic in methods:
`
def isValidAuthenticationMethod(self, usageType, configurationAttributes):
# Return false to trigger method call getAlternativeAuthenticationMethod
return False
def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
# Return "basic" or "cas"
# Get request from (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest() in order to analyze it
return None
`