Way to access the "names" database? dialplan funct

I know there is the directory application which allows me to enter the first 3 letters of a user’s last name and ring their respective extension.

I would like to be able to compare the user’s name with their extension, having both be input by the caller…

basicilly to use as a security function… however I cannot find a way to get a return value out of the directory application…

nor can I find a way to access the names via the dialplan…

my thought was to read a users DTMF input for extension number
then read users input for the name…

then compare the two to make sure the extension and user both match each other…

how do i access the name?
how do I access the extension number of the user?

I hate to modify the source for the directory application as then everytime I have to update asterisk i am going to lose my changes and have to make them again and that will get very tedious…

so I am hoping someone can point me to a dialplan function that helps out with this or that I can feed arguments to the directory function and get a return value back from it…

-Christopher