

be the account the user logged in with get the current identity from this app, it will boolean to hold membership test results Private void Form1_Load( object sender, EventArgs e) / Collect and display security information The class also shows some additional security related information that can be obtained on the user. In general, the class obtains the current user's identity information and examines that user against built-in and specific groups to test for membership. This section is annotated and should be easy enough to follow from the notation. The form load event is used to capture the security related information used to display security related information regarding the current logged in user. The class begins with the default imports (all of the imports are set by default):įollowing the imports, the namespace and class declaration are shown:įollowing the class declaration, the default constructor appears. The form class contains a single label control which is used to display the results of a couple of quick tests during operation, it will look like the screen shot shown in Figure 1.
#USING DESKTOP GROUPS CODE#
In this case, all of the code necessary to run the demo is contained in a single form class entitled "Form1". The solution contains a single application project called "Securit圜heck". Open the application and examine the contents in the solution explorer. In order to get started, unzip the included project and save it to your hard drive. There are other ways to accomplish the same sort of thing and to accomplish control level locking and the other approaches can be a bit more surgical however, this is approach is quite easy and may be used to good effect.įigure 1: Example Desktop Application Showing Group/Identity Information

If one were to check for group membership in the administrator's group, the application can show or hide such functionality by getting the currently logged in user and checking whether or not that user is a group member. For example, you might be working with an application that has administrative and general users the administrative users might have additional application rights such as the ability to delete records. The example shown would be useful for a client-server application in which it was, for example, necessary to restrict access to certain parts of the available functionality based upon the member's role.
#USING DESKTOP GROUPS WINDOWS#
The approach shown relies upon the use of the user's current Windows identity. This article describes a simple approach to determining whether or not a logged in user is a member of a group within the context of a desktop application.
