Check if the current user belongs a specific Windows group/roleTag(s): Security Powerscript
You can connect to the ActiveDirectory or use some API but an easy way is to use a connection to SQL Server. Send the query :
SELECT is_member('mydomain\g_dept')
0 Current user is not a member of group or role. 1 Current user is a member of group or role. NULL Either group or role is not valid.