How to know the access of a user on a document when the agent 's running on the server

I have to get access (no access or reader access) of users (from a specified list) on a document. The problem is that my agent is running on the server, on all new or modified documents, and must send e-mail to all users who have at least a reader access on one of these documents.

And it seems very difficult to analyse ACL, NAB and database to get groups, roles, Authors and Readers fields and calculate the effective access (no access or reader access) of each user on each document.

I’m sure that a script function like HasReaderAccess() had been written by someone !

I have tried but…

So if you can help me…

Thanks !