Using user roles with InfoPath 2003

Lab 7 of the InfoPath labs discuss about the using user roles with InfoPath.

This is one of the most useful features in InfoPath. You can do anything with this based on the role. For example, the admin user can be shown some admin views which are not visible for a normal user.

We can even get this information in the attached code by using the following api:

bool userRole = thisApplication.User.IsUserMemberOf(@"Domain\Group");

if (userRole)
{
   //do something cool here
}

However, there is a catch here. This works only if the user who is accessing the form and the group specified in the user roles are of the same domain.

So, the following are the valid and invalid combinations

Invalid Combination:

User: AMERICA\Employees
Group: ASIA\SecurityGroup

Valid Combination:

User: AMERICA\Employees
Group: AMERICA\SecurityGroup