Role based security


Role based security

Name spaces to be used are:

using System.Security.Permissions;
using System.Security.Cryptography;
using System.Security.Policy;
using System.Security.Principal;




AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal usr = (WindowsPrincipal)System.Threading.Thread.CurrentPrincipal;

if (usr.IsInRole(WindowsBuiltInRole.Administrator) == true)

MessageBox.Show("admin");

Else

MessageBox.Show("guest");



Explanation:

The above snippet demonstrates how to implement the role based security.The code is self explanatory.


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: