I don't have a particular application in mind,
but what you are looking for is authentication
through a database. You'd have to have all
user accounts in an NIS style, and they'd
have to reside in a SQL database of some
description. To get a better idea of what I
am talking about (big evil grin) go to Freshmeat
and search for PAM & SQL.