Navigation:  ROLE AND ROLE MANAGEMENT >

4.2.2 Example: Listing a Users Membership

Previous page Next page
  rev. 2007-12-04        

As an example let’s display all the RoleMembership contained by the user “cpowers”.

// Get the user with the username "cpowers"

User user = api.UserManager.GetUserByUserName("cpowers");

 

// Display a list of the roles "cpowers" has a membership to

foreach (ManagingEnergy.Security.RoleMembership membership in user.RoleMemberships)

  Console.WriteLine(membership);

 

// OUTPUT

Editor (deny) : ManagingEnergy_Template : All Projects

User Manager : All Data Sources

Administrator : All Data Sources

 

From the output we can see that the user “cpowers” has Administrative access to all Data Sources. However, cpowers also has a membership which denies the ability to edit anything within the Data Source “ManagingEnergy_Template”.



4.2.2_Example_Listing_a_Users_         ©2017 Managing Energy Inc.