write permission to a perticular user to a directory

Hi,
The requirement is like,
the program needs 2 argument one is user_id and second one is directory path. My script will check if that user_id has write access to the directory path. The directory path may be in any file system like AFS or NFS.
Can any one please suggest some points to procceed? I have written somthing which works fine for NFS not for AFS. My logic is checking if the said user_id is the owner and 'u' part of the prmission rwx or not, similalry if it not owner, then chek if belongs to group of that directory owner and like wise.

Please state which Operating System and version you have.
Please post the script and any relevant error messages.