Wrox Programmer Forums
Welcome to the p2p.wrox.com Forums.

You are currently viewing the WinForms/Console Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 6th, 2009, 10:07 AM
bex bex is offline
Friend of Wrox
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default How to check Windows Loged User

Hi there i need to show/hide a button in form1 based on user roles,

If Logedin User = Administrator then



how do i do this?

I found this on the web but not good:
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I check whether a user is logged in or out rittwick PHP Databases 1 August 19th, 2007 04:47 PM
Check Windows-Password Bernd VS.NET 2002/2003 1 October 6th, 2005 12:32 PM
Run DTS with a windows user, not a SQL user Kalli SQL Server DTS 1 September 15th, 2005 11:53 PM
Need help creating Check List Box of Windows Dir RBC827 VB.NET 2002/2003 Basics 2 August 10th, 2004 11:38 AM
How to check if a windows program is running in c beardje2000 C++ Programming 0 December 17th, 2003 01:49 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.