If you are using a declarative approach, then yes - if you suddenly do not want members to Supervisorbe able to call your method, you need to change the source code for this.
You can also programmatically do all this in code:
private void someMethod()
{
WindowsPrincipal currentUser = (Thread.CurrentPrincipal as WindowsPrincipal);
if (currentUser != null)
{
if (currentUser.IsInRole("Supervisor"))
{
}
}
}
You can always get the current version of Windows in which your Winforms application is running, and you can call the method IsInRoleto check if this user is in this role. Of course, you can also make it all customizable, for example. read the required role from the configuration file, and if you want to allow everyone, just simply change the role as Usersor something
source
share