So you need to intercept a login flow, block it, do some stuff, then let it resumes, without doing the authentication yourself.
You can try implementing a subauthentication package, which is basically a simplified authentication package.
You will need to implement the different callbacks described here.
You can find a basic example in the microsoft classic samples