Question about "Roles.GetAllRoles();"

Last post 04-30-2008 6:54 PM by johram. 1 replies.

Sort Posts:

  • Question about "Roles.GetAllRoles();"

    04-30-2008, 5:54 PM
    • Member
      690 point Member
    • AppDevForMe
    • Member since 12-31-2005, 6:19 PM
    • Posts 852

    I am maintaining some C#/asp.net code, which I think accesses active directory?
    The code has the following line of code in it:

      string[] allRoles = Roles.GetAllRoles();


    If I look at the definition of the class "Roles" it appears to have no code in it.
    Only comments. The comments follow the method names, but no definition for the methods
    are given. So I have concluded that this is some type of .NET system level class that is not
    accessible. Am I correct?

    Also basically here is the problem which I am really trying to fix:

    A call to the method Roles.GetAllRoles(); returns the following list of items, which are stored in the string "allRoles";

    Administrator
    Manager
    Contributor
    Donator
    Owner
    Viewer

    So, how do I alter the string "allRoles" so that it excludes the values "Contributor" and "Donator"?

    Or better yet, are these values stored in Active Directory? If so, how do I access the active directory
    database that contains the roles, so that I may delete the items  "Contributor" and "Donator"?

  • Re: Question about "Roles.GetAllRoles();"

    04-30-2008, 6:54 PM
    Answer
    • All-Star
      28,218 point All-Star
    • johram
    • Member since 06-13-2006, 10:36 AM
    • Sweden
    • Posts 3,543
    • Moderator

    Check out the web.config. In there should be a directive called roleManager that tells you how roles are configured. Role definitions typically reside in an SQL database (default scenario), or an XML (azman scenario).

    Here's an article on MSDN which explains how everything is set up and how to maintain roles: http://msdn.microsoft.com/en-us/library/ms998314.aspx

    As for your findings regarding "no code" for Roles class - that's how all framework classes look if you do a "go to definition". They are never shown with actual code, only method names and comments. But there is indeed code behind every method in that class, it is just hidden.

    If this post was useful to you, please mark it as answer. Thank you!
Page 1 of 1 (2 items)