I've done this before with a Virtual Directory. If you are looking for something Open Source and know Java, I would suggest ApacheDS. I've had success building custom backends for that directory before.
Marc