Results 1 to 7 of 7

Thread: Is there a way to read the actual Role from code

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Question Is there a way to read the actual Role from code

    Is there a way to read the actual Role of a user on the Network from code rather than having to pass in the String of that role?
    I want to know the "MyLAN\Web Dev Group" from an object of some sort. Does it exist?
    THanks

    Code:
    If HttpContext.Current.User.IsInRole("MyLAN\Web Dev Group") Then...

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    A user is usally in many roles. You could probably use the DirectorySevices namespace to get the group object but find who belongs to it. Although the objects there tend to be a bit generic.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    So I take it that this namespace actually can query the Active Directory?

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Yes.

    This is an example of getting all the groups a user belongs to:
    http://www.vbcity.com/forums/topic.a...1346&#RID64857

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    Originally posted by Edneeis
    Yes.

    This is an example of getting all the groups a user belongs to:
    http://www.vbcity.com/forums/topic.a...1346&#RID64857

    Hey that is great code on the other site! Did you actually implement it?

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Yes I made a custom RoleUser class for misc things and a role based security thing I had to do.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    I just implemented your code! Thanks for the work, it is VERY useful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width