Hi there i need to show/hide a button in form1 based on user roles,
If Logedin User = Administrator then
btn1.show
else
hide
how do i do this?
I found this on the web but not good:
Code:
String sddlAdmins = "S-1-5-32-544"; //Sid of administrators group
IdentityReference AdminsSid = new SecurityIdentifier(sddlAdmins);
WindowsIdentity wid = new WindowsIdentity(Environment.UserName);
_isAdministrator = wid.Groups.Contains(AdminsSid);
if (_isAdministrator)
Console.WriteLine(Environment.UserName + " is running with admin rights!");
_is Administrator is not defined
thanks