Help!

So I know the basics of batch files and how to map drives. How do I
say, "only connect this drive if they are in this security group?"

I know I use the following command to connect, but how do i say if
your in the PUBPOL group?

net use p: \\SERVER\fileserver\PUBLIC POLICY

any help would be greatly appreciated.