You will need to create a small web service that connects to that database, and when receives a redirect with those parameters prompts the user for username and password and then redirects the user back to Discourse.
Ok, this means, when discourse redirect to my web service i show a login page? I thinked discourse use his login, and redirect to me after user press on login button
When using DiscourseConnect we will just redirect every user login to a service you own, so you have 100% control over the whole signup, login, password requirement, group membership, etc.